View Single Post
  #5  
Old 01-03-2018, 17:34
chants chants is offline
VIP
 
Join Date: Jul 2016
Posts: 725
Rept. Given: 35
Rept. Rcvd 48 Times in 30 Posts
Thanks Given: 666
Thanks Rcvd at 1,050 Times in 475 Posts
chants Reputation: 48
That C code has become a bit prehistoric these days. I am not sure if timeb is portable either (though certainly with conditional compilation the prior snippet can be made to port on Windows and Linux for low 1ms resolution timer).

Here is STL C++ code for high resolution and portable code, requires no coding and mostly just ugly namespace declaration and templates.

Quote:
#include <chrono>
std::chrono::time_point<std::chrono::high_resolution_clock> start = std::chrono::high_resolution_clock::now();
//do things
std::chrono::duration<double, std::milli> elapsed = std::chrono::high_resolution_clock::now() - start;
printf("\nProcessing time %8.3f seconds\n", elapsed.count());
Reply With Quote
The Following 3 Users Say Thank You to chants For This Useful Post:
Indigo (07-19-2019), sendersu (01-03-2018), tonyweb (01-06-2018)