Skip to content

Commit eab43cc

Browse files
HJLebbinkTest User
authored andcommitted
added CRC32, CRC32C, SHA1, SHA256 and CRC64NVME
1 parent 1b7ae9e commit eab43cc

22 files changed

+3412
-53
lines changed

Cargo.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ http2 = ["reqwest/http2"]
2424
localhost = []
2525

2626
[workspace.dependencies]
27-
uuid = "1.18"
27+
uuid = "1.19"
2828
futures-util = "0.3"
2929
futures-io = "0.3"
3030
reqwest = { version = "0.12", default-features = false }
@@ -49,7 +49,7 @@ async-stream = "0.3"
4949
async-trait = "0.1"
5050
base64 = "0.22"
5151
chrono = { workspace = true, features = ["serde"] }
52-
crc = "3.4"
52+
crc-fast = "1.8"
5353
dashmap = "6.1.0"
5454
env_logger = "0.11"
5555
hmac = { version = "0.12", optional = true }
@@ -64,6 +64,7 @@ regex = "1.12"
6464
ring = { version = "0.17", optional = true, default-features = false, features = ["alloc"] }
6565
serde = { version = "1.0", features = ["derive"] }
6666
serde_json = "1.0"
67+
sha1 = "0.10"
6768
sha2 = { version = "0.10", optional = true }
6869
urlencoding = "2.1"
6970
xmltree = "0.12"
@@ -104,3 +105,8 @@ name = "load_balancing_with_hooks"
104105
name = "s3-api"
105106
path = "benches/s3/api_benchmarks.rs"
106107
harness = false
108+
109+
[[bench]]
110+
name = "bench_checksums"
111+
path = "benches/bench_checksums.rs"
112+
harness = false

benches/bench_checksums.rs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
// MinIO Rust Library for Amazon S3 Compatible Cloud Storage
2+
// Copyright 2025 MinIO, Inc.
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
16+
use criterion::{Criterion, Throughput, criterion_group, criterion_main};
17+
use minio::s3::utils::{
18+
crc32_checksum, crc32c, crc64nvme_checksum, md5sum_hash, sha1_hash, sha256_checksum,
19+
};
20+
21+
fn bench_checksums(c: &mut Criterion) {
22+
let sizes = vec![
23+
("1KB", 1024),
24+
("10KB", 10 * 1024),
25+
("100KB", 100 * 1024),
26+
("1MB", 1024 * 1024),
27+
("10MB", 10 * 1024 * 1024),
28+
];
29+
30+
for (name, size) in sizes {
31+
let data = vec![0u8; size];
32+
33+
let mut group = c.benchmark_group(format!("checksum_{}", name));
34+
group.throughput(Throughput::Bytes(size as u64));
35+
36+
group.bench_function("CRC32", |b| b.iter(|| crc32_checksum(&data)));
37+
38+
group.bench_function("CRC32C", |b| b.iter(|| crc32c(&data)));
39+
40+
group.bench_function("CRC64NVME", |b| b.iter(|| crc64nvme_checksum(&data)));
41+
42+
group.bench_function("MD5", |b| b.iter(|| md5sum_hash(&data)));
43+
44+
group.bench_function("SHA1", |b| b.iter(|| sha1_hash(&data)));
45+
46+
group.bench_function("SHA256", |b| b.iter(|| sha256_checksum(&data)));
47+
48+
group.finish();
49+
}
50+
}
51+
52+
criterion_group!(benches, bench_checksums);
53+
criterion_main!(benches);

0 commit comments

Comments
 (0)