Use a common macro to instrument each part
This commit is contained in:
8
crates/common/Cargo.toml
Normal file
8
crates/common/Cargo.toml
Normal file
@@ -0,0 +1,8 @@
|
||||
[package]
|
||||
name = "common"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
||||
14
crates/common/src/lib.rs
Normal file
14
crates/common/src/lib.rs
Normal file
@@ -0,0 +1,14 @@
|
||||
use std::time::Instant;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! instrument {
|
||||
($part1:expr, $part2:expr) => {
|
||||
let mut now = Instant::now();
|
||||
println!("Part 1: {}", $part1);
|
||||
println!("(elapsed: {:?})", now.elapsed());
|
||||
now = Instant::now();
|
||||
println!("");
|
||||
println!("Part 2: {}", $part2);
|
||||
println!("(elapsed: {:?})", now.elapsed());
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user