How to create a macro that measures the function?

52 points zxaq15

My goal is creating a macro like this.

///// I want to define a macro like this
let now = Instant::now()
some_func()
println!("elapsed: {]", now.elapsed().as_millis());
/////



#[measure_time] // macro name
fn my_func() {
    ...
}

when I call the my\_func with a macro, I want to see "elasped: .." (like python's decorator)

How to do this?