function_benchmarker 0.1.1

A proc macro for benchmarking Rust code
Documentation

benchmarker

A simple and efficient benchmarking tool for Rust functions.

Crates.io Documentation License: MIT

Features

  • Easy-to-use macro for benchmarking functions
  • Measures execution time and calculates statistics
  • Supports multiple iterations for accurate results
  • Customizable number of warmup rounds

Usage

Add this to your Cargo.toml:

[dependencies]
benchmarker = "*"

Then, you can use the bench macro to benchmark your functions:

use function_benchmarker::benchmark;

use core::time;
use std::thread;

#[benchmark]
fn log_function() {
    for num in 0..10 {
        thread::sleep(time::Duration::from_secs(1));
        println!("{}", num);
    }
}

fn main() {
    log_function();
}

output:
Entering function: log_function
0
1
2
3
4
5
6
7
8
9
Exiting function: log_function (took 10038 ms)

This will print the average time taken to execute the function and other statistics.

License

This project is licensed under the MIT License. See the LICENSE file for more details.