Files
rustfs/rustfs/benches/s3_operations.rs
T

82 lines
2.7 KiB
Rust

// Copyright 2024 RustFS Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! S3 Operations Benchmarks
//!
//! These benchmarks measure the performance of core S3 operations:
//! - PutObject: Upload object to storage
//! - GetObject: Download object from storage
//! - ListObjects: List objects in a bucket
//!
//! Run with: cargo bench --bench s3_operations
use criterion::{BenchmarkId, Criterion, criterion_group, criterion_main};
use std::hint::black_box;
/// Benchmark PutObject operation (simulated)
fn bench_put_object(c: &mut Criterion) {
let mut group = c.benchmark_group("put_object");
for size in [1024, 1024 * 1024, 10 * 1024 * 1024] {
let data = vec![0u8; size];
group.bench_with_input(BenchmarkId::from_parameter(size), &data, |b, data| {
b.iter(|| {
// Simulate PutObject operation
// In a real benchmark, this would call the actual S3 client
black_box(data.len());
});
});
}
group.finish();
}
/// Benchmark GetObject operation (simulated)
fn bench_get_object(c: &mut Criterion) {
let mut group = c.benchmark_group("get_object");
for size in [1024, 1024 * 1024, 10 * 1024 * 1024] {
let data = vec![0u8; size];
group.bench_with_input(BenchmarkId::from_parameter(size), &data, |b, data| {
b.iter(|| {
// Simulate GetObject operation
// In a real benchmark, this would call the actual S3 client
black_box(data.len());
});
});
}
group.finish();
}
/// Benchmark ListObjects operation (simulated)
fn bench_list_objects(c: &mut Criterion) {
let mut group = c.benchmark_group("list_objects");
for count in [10, 100, 1000] {
group.bench_with_input(BenchmarkId::from_parameter(count), &count, |b, count| {
b.iter(|| {
// Simulate ListObjects operation
// In a real benchmark, this would call the actual S3 client
black_box(count);
});
});
}
group.finish();
}
criterion_group!(benches, bench_put_object, bench_get_object, bench_list_objects);
criterion_main!(benches);