All Projects → juzi5201314 → bench-rs

juzi5201314 / bench-rs

Licence: MIT license
A benchmark library.

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to bench-rs

golden
a benchmark for compile-time and/or runtime Nim 🏆
Stars: ✭ 28 (+100%)
Mutual labels:  bench
prettyBenching
🦕 A small lib to make your Deno benchmarking progress and results look pretty
Stars: ✭ 23 (+64.29%)
Mutual labels:  bench

bench-rs

Rust docs.rs GitHub code size in bytes Downloads GitHub Crates.io

A benchmark library.

  • Stable rust (no black_box)
  • Beautiful output
  • Async support
  • Custom async runtime
  • Memory usage
  • Custom formatting
  • Intuitive numerical units
  • Support custom memory allocator

Examples

$ cargo test --release --color=always -q --package bench-rs --test bench --no-fail-fast -- --test-threads=1 --nocapture

Look ./tests/bench.rs

image.png

black_box

I don't know how to implement the black box.

Please use core::hint::black_box. (unstable)

If you have a better idea, welcome to submit a pull request or open an issue

global_allocator

In order to detect Memory usage, bench-rs modified global_allocator. This will make it impossible to use other allocators. If you need to use other allocator:

Change your allocator: (if your allocator is std::alloc::System)

use std::alloc::System;
use bench_rs::{TrackAllocator, new_allocator};

#[global_allocator]
pub static GLOBAL: TrackAllocator<System> = new_allocator!(System);

Turn off default features:

[dependencies]
bench-rs = { version = "*", default-features = false }

Import the allocator named GLOBAL:

use bench_rs::bench;
use yourlib::GLOBAL;

#[bench]
fn ...

If your allocator name is not GLOBAL, please set its alias to GLOBAL:

use yourlib::OtherAllocator as GLOBAL

Because the bencher-macro will look for GLOBAL.counter() and GLOBAL.peak() at the same level of the bench function.


I am a rust beginner, please correct me if the code is bad. Thank you

Contributions welcome

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].