Skip to content

Instantly share code, notes, and snippets.

View PY44N's full-sized avatar
💭
Non est ad astra mollis e terris via

Ryan PY44N

💭
Non est ad astra mollis e terris via
View GitHub Profile
@PY44N
PY44N / profiler.rs
Created July 6, 2023 17:56
A simple function for profiling Rust code
use lazy_static::lazy_static;
lazy_static! {
static ref PROFILED_SPEEDS: Mutex<HashMap<String, Vec<u64>>> = Mutex::new(HashMap::new());
}
fn profile<T>(name: &str, test: &mut impl FnMut() -> T) -> T {
let start = SystemTime::now()
.duration_since(UNIX_EPOCH)
.unwrap()