sapling/eden/scm/lib/lz4-pyframe/benches/bench.rs
Adam Simpkins ab3a7cb21f Move fb-mercurial sources into an eden/scm subdirectory.
Summary:
In preparation for merging fb-mercurial sources to the Eden repository,
move everything from the top-level directory into an `eden/scm`
subdirectory.
2019-11-13 16:04:48 -08:00

30 lines
720 B
Rust

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
use lz4_pyframe::{compress, decompress};
use minibench::{bench, elapsed};
use rand_core::{RngCore, SeedableRng};
fn main() {
let mut rng = rand_chacha::ChaChaRng::seed_from_u64(0);
let mut buf = vec![0u8; 100_000000];
rng.fill_bytes(&mut buf);
let compressed = compress(&buf).unwrap();
bench("compress (100M)", || {
elapsed(|| {
compress(&buf).unwrap();
})
});
bench("decompress (~100M)", || {
elapsed(|| {
decompress(&compressed).unwrap();
})
});
}