I wrote a hackish benchmark program so you can compare your computers to my aging little machine
here's the code
note: the lower the percentage the better.Code:#include <iostream> #include <cstring> #include <ctime> using namespace std; int sl; void inline swt(unsigned char *tp, int x, int y) { char tmp; tmp = tp[x]; tp[x] = tp[y]; tp[y] = tmp; } void inline perm(unsigned char *tp, int pl) { if (pl == sl - 1) { // cout << tp << endl; } for (int nc = pl; nc < sl; nc++) { swt(tp, pl, nc); perm(tp, pl + 1); } } int main(void) { unsigned char str[] = "nosebleeding"; double brispeed = 26.8300F; double bripercent = brispeed / 100; double yourspeed; double yourpercent; clock_t start, end; sl = strlen((const char*)str); start = clock(); perm(str, 0); end = clock(); yourspeed = (double)(end - start) / (double)CLOCKS_PER_SEC; yourpercent = yourspeed / bripercent; cout << "The program took " << yourspeed << " seconds. That's " << yourpercent << "% of the time " << "Brian's computer took." << endl; return 0; }
my output:
Code:bash-2.05b$ ./test The program took 26.8216 seconds. That's 99.9687% of the time Brian's computer took.this will be wildly inaccurate due to compiler optimisations and such, but it's just for fun.Code:Specs: 1.00GHz AMD Athlon 512MB RAM FreeBSD 4.9 GCC 3.3.3



LinkBack URL
About LinkBacks


