Timeline for answer to Getting an accurate execution time in C++ (micro seconds) by OlivierLi
Current License: CC BY-SA 4.0
Post Revisions
17 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Feb 15, 2022 at 16:23 | history | edited | Gabriel Staples | CC BY-SA 4.0 |
roll over the cmd to the next line to remove having to scroll horizontally
|
| Jul 17, 2020 at 11:22 | comment | added | Arthur Tacca |
It's basically always wrong to use std::high_resolution_clock. It is an alias for either std::steady_clock or std::system_clock, and they have very different characteristics, so you should make a conscious decision of which one is appropriate for you (almost certainly std::steady_clock to time how long something takes) and stick with that.
|
|
| Mar 3, 2020 at 23:20 | history | edited | Peter Cordes | CC BY-SA 4.0 |
general tips about microbenchmark pitfalls.
|
| Nov 1, 2016 at 23:51 | comment | added | Veridian | Using eclipse in windows and I get "Function 'now' could not be resolved' on that first line: auto start = std::chrono::high_resolution_clock::now(); However, it works fine in linux. What's the deal? | |
| Jan 13, 2016 at 1:50 | history | edited | OlivierLi | CC BY-SA 3.0 |
added 9 characters in body
|
| Aug 25, 2014 at 3:37 | comment | added | Xavi Montero |
I see. Answer myself. Should be: high_resolution_clock::time_point (example here: cplusplus.com/reference/chrono/high_resolution_clock/now ) - or std::chrono::high_resolution_clock::time_point in case of not using the namespace.
|
|
| Aug 25, 2014 at 3:33 | comment | added | Xavi Montero |
btw, if I can't use auto, which data type should I use for std::chrono::high_resolution_clock::now()?
|
|
| Feb 24, 2014 at 10:52 | vote | accept | user3323616 | ||
| Feb 24, 2014 at 10:49 | vote | accept | user3323616 | ||
| Feb 24, 2014 at 10:49 | |||||
| Feb 18, 2014 at 16:21 | comment | added | stefan | @qdii Right, that is an application. But would you really do this by measuring just the time? You surely need a profiler to identify what part causes the high set-up time. The start-up of any program should "feel instantaneous". You don't really need to measure this imho. | |
| Feb 18, 2014 at 16:03 | comment | added | qdii | @stefan hm, for instance, I could want to do that because I am a game developer and I want to know how long it takes for my game to start specifically on Windows 8, for instance. As a developer, I have an impact on how large the executable is: I can embed resources in the binary executable's sections, strip symbols, optimize for space, etc. I think the question needs to be clarified so as what exactly is to be measured. | |
| Feb 18, 2014 at 15:58 | comment | added | stefan | @qdii Exactly, different OS have different set-up times. That's why. You're not measuring the apps performance, but the OS performance, if you include that bit. Why would you do that? Unless you're an OS developer, you can't do anything about the set-up time. Even on one OS, the hard disk may need to spin up in order to read the executable. Do you really want to measure that to a microsecond precision? | |
| Feb 18, 2014 at 15:55 | comment | added | qdii | @stefan: what makes you say so? reading the executable from disk to memory can be expensive. In addition, different OS have different set-up systems, can you confirm that all of them load the program in less than a microsecond?. It might all be irrelevant in the end, but I don’t think we should ignore them. | |
| Feb 18, 2014 at 15:22 | comment | added | stefan | @qdii to test the performance of a program on the scale of microseconds, the set-up and destruction part should be ignored. | |
| Feb 18, 2014 at 14:58 | comment | added | qdii | -1: this is good to time a function, but not to time a program, since you are missing the set-up and destruction part of the program by the OS. | |
| Feb 18, 2014 at 14:29 | comment | added | user2249683 | Note: In g++ nanoseconds are available since GCC 4.8.1. | |
| Feb 18, 2014 at 14:09 | history | answered | OlivierLi | CC BY-SA 3.0 |