3 unstable releases
0.2.1 | Nov 13, 2024 |
---|---|
0.2.0 | Nov 13, 2024 |
0.1.0 | Nov 7, 2024 |
#1165 in Concurrency
79 downloads per month
Used in kolbold
96KB
1.5K
SLoC
Performance Measurement Library
This library provides tools for measuring the time and memory complexity of code, supporting both synchronous and asynchronous operations. It is designed for developers who need to benchmark their code in multi-threaded or single-threaded environments.
Modules
common_collector
: A common interface for both thetime
&memory
modules, combining the functionality of botherror
: Custom error handling types used across the library.memory
: Functions and traits for memory complexity measurement.system_metrics
: Structures and traits for collecting system-level metrics.thread_metrics
: Data structures for holding thread-specific metric data.time
: Functions and traits for time complexity measurement.time_handle
: An abstraction for the time elapsed logic used across the library.utils
: Utility functions used throughout the library.
Re-exports
The library re-exports the most commonly used traits and structs for easier access:
MemoryComplexity
andMemoryMeasurement
for memory complexity measurement.TimeComplexity
andTimeMeasurement
for time complexity measurement.
Example Usage
use kolbold_core::{TimeComplexity, MemoryComplexity, TimeMeasurement, MemoryMeasurement};
// Measure time complexity of a single-threaded synchronous process
TimeMeasurement::measure_single_thread_sync::<_, _, TimeMeasurement>(|| {
// Your process to benchmark
})
.map(|result| println!("Time measurement successful: {:?}", result))
.unwrap_or_else(|e| eprintln!("Failed to measure time complexity: {}", e));
// Measure memory complexity of an async process
MemoryMeasurement::measure_single_thread_async::<_, _, MemoryMeasurement>(|| {
// Your async process to benchmark
})
.await
.map(|result| println!("Memory measurement successful: {:?}", result))
.unwrap_or_else(|e| eprintln!("Failed to measure memory complexity: {}", e));
Getting Started
- Import the
TimeMeasurement
orMemoryMeasurement
structs for access to measurement methods. - Use the traits
TimeComplexity
andMemoryComplexity
to implement custom measurement strategies if needed.
Dependencies
~15–25MB
~464K SLoC