Is this a good way to use timers in c++ for all platforms? or is there a better alternative, I ask this because I'm trying to find an accurate and cross platform solution for measuring time on all machines that run at different speeds,and preferably measured in milliseconds.
It is okay way to measure wall clock, but your method or measuring execution time is bad:
1) high_resolution_clock is a wall clock, that means it measures time in real world, not time spent on current process: if, for example, OS will pause this program execution to give CPU time for other program (this is how multitasking works), your calculation will be wrong. Use clock() function;
2) Your code does not test RandomRange function speed, but console output speed. Console output is slow, any time spent by RandomRange will be within standard error for output time and therefore unmeasureable.
3) RandomRange is itself bad: it is very predictable and not really random as you explicitely set seed on each iteration and not even bother to warm-up generator. Why not use proper C++11 random facilities?
Thank you for your reply that helped allot concerning the use of time functions in c++. And yes my random number generator is bad I'm still yet to learn how to use c++11 random generator engines and I'm fully aware of Cout being a slow function,just wanted random numbers to be printed :).
what I really needed to know was if this was good for measuring real time for all operating systems and machines in c++,I've been lost on this for a little while now.So thanks again