function_benchmarker 0.1.2

A proc macro for benchmarking Rust code
Documentation
# benchmarker

A simple and efficient benchmarking tool for Rust functions.

[![Crates.io](https://img.shields.io/crates/v/benchmarker.svg)](https://crates.io/crates/benchmarker)
[![Documentation](https://docs.rs/benchmarker/badge.svg)](https://docs.rs/benchmarker)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/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`:

```toml
[dependencies]
chrono = "0.4.38"
jemalloc-ctl = "0.5.4"
jemallocator = "0.5.4"
benchmarker = "*"
```

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

```rust

#[global_allocator]
static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
use function_benchmarker::benchmark;


#[benchmark]
pub fn test_benchmark(limit: u64) -> Vec<u64> {
    // Function to calculate prime numbers efficiently
    if limit <= 1 {
        return vec![];
    }

    let mut is_prime = vec![true; limit as usize + 1];
    is_prime[0] = false;
    is_prime[1] = false;

    let sqrt_limit = (limit as f64).sqrt() as u64;
    for i in 2..=sqrt_limit {
        if is_prime[i as usize] {
            let mut j = i * i;
            while j <= limit {
                is_prime[j as usize] = false;
                j += i;
            }
        }
    }

    (2..=limit).filter(|&i| is_prime[i as usize]).collect()
}

fn main() {
    // Benchmark the prime calculation function
    let limit: u64 = 1_000_000;
    let primes = test_benchmark(limit);
    println!("Number of primes up to {}: {}", limit, primes.len());
}

output:
Entering function: test_benchmark
Exiting function: test_benchmark (took 61 ms) memory used: 1732224 bytes
Number of primes up to 1000000: 78498
```

This will print the average time taken to execute the function and memory statistics.
## License

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