Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::time::Instant;
- struct Profile {
- lbl: &'static str,
- start: Instant,
- }
- impl Profile {
- pub fn new(lbl: &'static str) -> Self {
- Profile {
- lbl,
- start: Instant::now(),
- }
- }
- }
- impl Drop for Profile {
- fn drop(&mut self) {
- println!("{} {:?}", self.lbl, self.start.elapsed());
- }
- }
- fn main() {
- {
- let _prof = Profile::new("foo");
- println!("work work work");
- }
- }
Add Comment
Please, Sign In to add comment