Expand description
§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&memorymodules, 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:
MemoryComplexityandMemoryMeasurementfor memory complexity measurement.TimeComplexityandTimeMeasurementfor 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
TimeMeasurementorMemoryMeasurementstructs for access to measurement methods. - Use the traits
TimeComplexityandMemoryComplexityto implement custom measurement strategies if needed.
Re-exports§
pub use memory::memory_measurement::MemoryComplexity;pub use memory::memory_measurement::MemoryMeasurement;pub use time::time_measurement::TimeComplexity;pub use time::time_measurement::TimeMeasurement;
Modules§
- common_
collector - error
- Error Handling Module
- memory
- system_
metrics - System Metrics Collection Module
- thread_
metrics - Thread Metrics Module
- time
- time_
handle - Timer Trait Module
- utils