i have a c++ and java program which both work. I know what i need to do in java now but not c++. The program gets the work done, but how can i time it? All examples i seem to be getting to test the speed are unix specific. This is my program
Code:
#include "stdafx.h"
#include <set>
#include <iostream>
using namespace std;
class RInteger {
private:
int i;
public:
RInteger(int v) { i = v; }
friend ostream& operator <<(ostream& o, const RInteger &ri);
inline friend bool operator <(const RInteger a, const RInteger b);
};
ostream&
operator <<(ostream& o, const RInteger &ri)
{
cout << ri.i;
return o;
}
inline bool
operator <(const RInteger a, const RInteger b)
{
return (b.i < a.i);
}
int main(int argc, char *argv[])
{
set <RInteger> s;
int i;
int rand = 10;
for (i = 0; i < 1000000; i++) {
s.insert(RInteger(rand));
rand = rand * 1103515245 + 12345;
}
set<RInteger>::const_iterator si;
for (i = 0, si = s.begin(); si != s.end(); i++, si++)
if (i % 100000 == 0)
cout << *si << '\n';
return 0;
}
So somehow i need to print out the starting time, and the ending time of this program. How would i add this to my program which would work? (using windows vista, visual c++ 2008).
cheers