Well
as the headline refere: does any one have a way to time you code , since i need one ( both on windows, but also on RHW( no os ))
KMT dk
Timing you code, how to do that ?`???
Timing you code, how to do that ?`???
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
Re: Timing you code, how to do that ?`???
Use the RDTSC instruction.
It has some pitfalls though, but its pretty much the only OS independent trick you can do.
It has some pitfalls though, but its pretty much the only OS independent trick you can do.
Re: Timing you code, how to do that ?`???
Code: Select all
#include <ctime>
#include <iostream>
using namespace std;
class timer
{
public:
timer() : start(clock()) { }
~timer();
private:
clock_t start;
};
inline timer::~timer()
{
cout << "timer took "<< double(clock()-start)/CLOCKS_PER_SEC
<< " seconds" << endl;
}
Re: Timing you code, how to do that ?`???
well
thx.
when i mean timing, i mean in mili secounds, ( sry not for telling ).
KMT dk
thx.
when i mean timing, i mean in mili secounds, ( sry not for telling ).
KMT dk
well, what to say, to much to do in too little space.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
when it goes up hill, increase work, when it goes straight, test yourself but when going down, slow down.
- AndrewAPrice
- Member
- Posts: 2299
- Joined: Mon Jun 05, 2006 11:00 pm
- Location: USA (and Australia)
Re: Timing you code, how to do that ?`???
Check here: http://en.wikipedia.org/wiki/RDTSC
Also their external link right at the bottom which reads: "cycle.h - C code to read the high-resolution timer on many CPUs and compilers."
Did you even look in to Combuster's response, which was direct and to the point?
Also their external link right at the bottom which reads: "cycle.h - C code to read the high-resolution timer on many CPUs and compilers."
Did you even look in to Combuster's response, which was direct and to the point?
My OS is Perception.