PDA

View Full Version : How do you compare?



Brian
11-09-2003, 12:17 PM
I wrote a hackish benchmark program so you can compare your computers to my aging little machine



here's the 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;
}


note: the lower the percentage the better.

my output:


bash-2.05b$ ./test
The program took 26.8216 seconds. That's 99.9687% of the time Brian's computer
took.




Specs:
1.00GHz AMD Athlon
512MB RAM
FreeBSD 4.9
GCC 3.3.3


this will be wildly inaccurate due to compiler optimisations and such, but it's just for fun.

ZakkWylde969
11-09-2003, 12:23 PM
Mine does nothing but show up as a black box for a couple minutes and nothing happens...

Brian
11-09-2003, 12:28 PM
Originally posted by ZakkWylde969
Mine does nothing but show up as a black box for a couple minutes and nothing happens...

hehe. maybe you should leave it on overnight :)

JaWiB
11-09-2003, 01:12 PM
Mine took 50.42 seconds (187.942% of your time)

My specs:


800mhz Intel Pentium III
256 RAM
Win 98
Whatever version of GCC Dev-C++ uses...

Oh yeah, and I was wondering about this:


unsigned char str[] = "nosebleeding";


Is there for...:confused:

ZakkWylde969
11-09-2003, 01:29 PM
my computer isn't THAT slow!

Iamien
11-09-2003, 01:34 PM
The program took 19.484 seconds. Thats 72.6202% of the time Brian's computer took.
Fully optimized in Dev C++
athlon xp 1900+
360 ddr pc2100

UnregdRegd
11-09-2003, 02:00 PM
Do I win a prize?



The program took 16.694 seconds. That's 642.2214% of the time Brian's computer took.


Pentium 4 Mobile at 2.2 GHz
384-MB RAM
Windows XP Professional
Visual C++ 6.0, Standard Edition (i.e., no optimization)

confuted
11-09-2003, 04:45 PM
The program took 17.755 seconds. That's 66.1759% of the time Brian's computer took.

1.9 GHz, 256 mb RD800 RAM, WinXP Home, MSVC6 Pro on release mode, no special optimizations turned on (I forgot how)

Brian
11-09-2003, 05:52 PM
Originally posted by JaWiB

Oh yeah, and I was wondering about this:


unsigned char str[] = "nosebleeding";


Is there for...:confused:

The program finds all possible combinations the letters of the string "nosebleeding" can be in. (try uncommenting the cout << line)

JaWiB
11-09-2003, 08:37 PM
Ohh lol, I just glanced at your program at first and didn't really read it and thought "Why would he have a string like that there?"
Stupid me :o

...
11-09-2003, 09:51 PM
mine takes 18 seconds when i remove one letter from the end of the string... when i leave it like it is i just get impatient and close it.

my desktop took a solid minute and its a p4 2.8 with 1gig ram and MSVC++.NET, and my laptop i never even finish, and its a p4 mobile 2.0 with 512mb ram.

hmm......