#benchmark #logging #performance #measurement

aloe-performance-counter

A Rust crate for precision performance measurement and logging with automated statistical aggregation. This crate is a translation of the c++ juce module serving the same function.

1 unstable release

Uses new Rust 2024

new 0.1.1 Apr 3, 2025

#69 in #measurement

GPL-3.0 license

335KB
2K SLoC

Aloe Performance Counter

Aloe Performance Counter is a sophisticated Rust crate designed for precise and efficient performance monitoring of code segments. It enables users to measure execution time, aggregate statistical data, and log results seamlessly.

Key Features

  • High-Resolution Timing: Capture nanosecond-level timing metrics to accurately measure execution durations.
  • Statistical Aggregation: Analyze performance with averaged metrics over multiple runs, enhancing accuracy.
  • File-Based Logging: Directly log performance metrics to specified files, ensuring persistence and accessibility.
  • Automated Printouts: Configure the number of iterations after which averaged statistics are logged automatically.

Installation

Add this to your Cargo.toml:

[dependencies]
aloe-performance-counter = "0.1.0"

Usage

Here is a brief example demonstrating the implementation:

use aloe_performance_counter::PerformanceCounter;

fn main() {
    let mut pc = PerformanceCounter::new(&"example", Some(50), Some(&std::fs::File::open("/temp/log.txt").unwrap()));
    for _ in 0..1000 {
        pc.start();
        // code segment for performance measurement
        pc.stop();
    }
}

API

  • PerformanceCounter::new: Initializes a new PerformanceCounter object.
  • start: Marks the beginning of the time measurement.
  • stop: Ends the timing and logs statistics if required iterations are reached.
  • print_statistics: Outputs current stats for inspection.
  • get_statistics_and_reset: Retrieves and resets accumulating metrics.

Contributing

For guidance on setting up a development environment, see CONTRIBUTING.md.

License

Licensed under GPL-3.0. See LICENSE for details.


This README file was generated by an AI model and may not be 100% accurate. However, it should be a good starting point for understanding the crate.

This crate is a translation of the JUCE module.

JUCE is a c++ software framework for developing high performance audio applications.

Usage falls under the GPLv3 as well as the JUCE commercial license.

See github.com/juce-framework/JUCE and the JUCE license page for details.

This crate is in the process of being translated from c++ to rust. For progress updates, please see the workspacer rust project. designed specifically for rust projects.

Dependencies

~13–22MB
~355K SLoC