2020年12月23日星期三

rust performance in IDE and command line

I am a beginner of rust. I wrote a project with one main.rs and two module files. The dev environment is CLion+Intellij Rust plugin on MacOS 11.1. The program is a simple CPU-intensive computation task. To measure its performance, I used following method:

    let timer = Instant::now();      task();  // the main function of the task      println!("{:.2?}", timer.elapsed());  

When I ran the program in CLion's IDE, it prints a running duration of like 500~700µs.

However, if I ran the program (~project/target/debug/project) from command line in Mac Terminal, it prints 3~7ms. That's a difference one magnitude, which really confused me.

How to explain this difference? And any advice to improve the performance in command line? Thanks for any comments.

https://stackoverflow.com/questions/65433037/rust-performance-in-ide-and-command-line December 24, 2020 at 09:49AM

没有评论:

发表评论