Thread: How do you compare?

  1. #1
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212

    Wink How do you compare?

    I wrote a hackish benchmark program so you can compare your computers to my aging little machine



    here's the code
    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:
    Code:
    bash-2.05b$ ./test
    The program took 26.8216 seconds. That's 99.9687% of the time Brian's computer
    took.
    Code:
    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.
    Last edited by Brian; 11-09-2003 at 12:20 PM.

  2. #2
    ___
    Join Date
    Jun 2003
    Posts
    806
    Mine does nothing but show up as a black box for a couple minutes and nothing happens...
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  3. #3
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    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

  4. #4
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Mine took 50.42 seconds (187.942% of your time)

    My specs:
    Code:
    800mhz Intel Pentium III
    256 RAM
    Win 98
    Whatever version of GCC Dev-C++ uses...
    Oh yeah, and I was wondering about this:
    Code:
    unsigned char str[] = "nosebleeding";
    Is there for...
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  5. #5
    ___
    Join Date
    Jun 2003
    Posts
    806
    my computer isn't THAT slow!
    "When I die I want to pass peacefully in my sleep like my grandfather did, not screaming and yelling like the passengers in his car."

  6. #6
    Wen Resu
    Join Date
    May 2003
    Posts
    219
    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
    Last edited by Iamien; 11-09-2003 at 05:57 PM.

  7. #7
    Board Conservative UnregdRegd's Avatar
    Join Date
    Jul 2003
    Posts
    154
    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)
    I am a programmer. My first duty is to God, then to nation, then to employer, then to family, then to friends, then to computer, and finally to myself. I code with dignity, honor, and integrity.

  8. #8
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    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)
    Away.

  9. #9
    Registered User
    Join Date
    Jan 2002
    Location
    Vancouver
    Posts
    2,212
    Originally posted by JaWiB

    Oh yeah, and I was wondering about this:
    Code:
    unsigned char str[] = "nosebleeding";
    Is there for...
    The program finds all possible combinations the letters of the string "nosebleeding" can be in. (try uncommenting the cout << line)

  10. #10
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    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
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  11. #11
    Registered User
    Join Date
    Feb 2002
    Posts
    465
    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......
    I came up with a cool phrase to put down here, but i forgot it...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  2. compare strings not working
    By gtriarhos in forum C Programming
    Replies: 7
    Last Post: 09-29-2005, 12:51 PM
  3. Help Writing My Own String Compare
    By djwicks in forum C Programming
    Replies: 4
    Last Post: 04-07-2005, 09:44 PM
  4. String Compare Using Dynamic Arrays
    By djwicks in forum C Programming
    Replies: 4
    Last Post: 03-31-2005, 08:01 PM
  5. string compare
    By IceBall in forum C Programming
    Replies: 4
    Last Post: 10-12-2003, 05:26 PM