Benchmark - Monty Hall Problem

Posted:
in Current Mac Hardware edited January 2014
Here is a Perl script I found and modified that we can use as a benchmark for integer and general CPU performance of the old and new Macs, as well as other Intel and AMD machines.



The Monty Hall Problem was a hit on Marilyn vos Savant, Car Talk's Click and Clack's Puzzler, and drew responses from many mathematicians and statisticians. This simulation serves to verify that the contestant on Let's Make A Deal would have twice as good a chance at winning the car if she switches her choice to the other door. If this makes no sense to you, read about it at Wikipedia: http://en.wikipedia.org/wiki/Monty_Hall_problem



Open my iDIsk Public Folder (Finder->Go->iDisk->Other User's Public Folder), enter my ID "johnnylundy", and download the file "OSXAutoThreadMHP.pl" to your Desktop or other known place.



In Terminal,



cd /path/to/the/directory/of/the/file (e.g. "cd ~/Desktop"



chmod +x OSXAutoThreadMHP.pl



./OSXAutoThreadMHP.pl



The Perl script has two flags that you can set on the command line - the number of iterations or times to play the game, and the number of threads that you want. Set the iterations to ten million if you can. The script will auto-detect the number of cores, but if you want to have more threads just for fun (or force it to run as a single thread), you can use the "-c" flag. Here are examples:



./OSXAutoThreadMHP.pl -c 2 -i 10000000



the above example sets it to two cores (e.g. Core Duo or Dual G5) and ten million games played.



./OSXAutoThreadMHP.pl -c 4 -i 2000000



the above is quad processors and 2 million games played.



If both flags are omitted, the script will auto-detect the processor(s) and play 3000 games.



Cheers,

JL

Comments

  • Reply 1 of 18
    xoolxool Posts: 2,460member
    Interesting... What's the performance look like?
  • Reply 2 of 18
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by Xool

    Interesting... What's the performance look like?



    The Core Duos look good.



    No Quad results yet.
  • Reply 3 of 18
    Here's a quad result:



    Automatic Processor Detection found 4 processor cores.

    Playing 3000 games across 4 cores...



    Thread# 0 created.

    Thread# 1 created.

    Thread# 2 created.

    Thread# 3 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 993 times

    Switcher has won 2007 times

    Time elapsed for 3000 solutions was 0.040187 seconds.
  • Reply 4 of 18
    and a second run:



    Automatic Processor Detection found 4 processor cores.

    Playing 3000 games across 4 cores...



    Thread# 0 created.

    Thread# 1 created.

    Thread# 2 created.

    Thread# 3 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 1054 times

    Switcher has won 1946 times

    Time elapsed for 3000 solutions was 0.039975 seconds.
  • Reply 5 of 18
    flounderflounder Posts: 2,674member
    Cool. Looks like it's pretty reproducible then.
  • Reply 6 of 18
    Can someone share what those results mean? What are the results on other machines? Is processor speed or number of threads more important (or of equal importance)?
  • Reply 7 of 18
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by finchna

    Can someone share what those results mean? What are the results on other machines? Is processor speed or number of threads more important (or of equal importance)?



    This script is written to be thread-savvy, meaning if you tell it to do 10 million games on a Quad, it will assign 2.5 million games to each thread. The Mach kernel says, "hmmm, four threads, four cores, easy to figure this one out."



    So since there is no need for the overhead of the threads "communicating" with each other, the times should be close to half for double the cores, and so forth.



    This is the Perl interpreter running, so on different platforms it may be a more efficient Perl than on others. But comparing OS X to OS X, one should get decreasing time with increasing clockspeed and cores. Memory bandwidth, Altivec, disk, and display hardware should not be factors. However, these threads are set to normal priority, so if there are a lot of processes going on you will get slower times as Mach pre-empts the Perl interpreter.



    We can make a graph if we get 20 or 30 results.



    Enter 10 million as the number of games so we can get more precision.
  • Reply 8 of 18
    iMac Core Duo 2.0

    1.5 Gig Of Ram



    ---



    Automatic Processor Detection found 2 processor cores.

    Playing 10000000 games across 2 cores...



    Thread# 0 created.

    Thread# 1 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 3334016 times

    Switcher has won 6665984 times

    Time elapsed for 10000000 solutions was 40.045025 seconds.
  • Reply 9 of 18
    lundylundy Posts: 4,466member
    Here are some of the times that we found in the DSLR crowd (the formatting is screwed up - tabs don't like forum posting text boxes):

    Quote:

    Proc\tSpeed (gHz)\tCores\tTime (secs)

    G5\t2.50\t4\t37.50

    Opteron175\t3.10\t2\t28.67

    Athlon64\t2.20\t2\t29.46

    Intel Core Duo\t1.83\t2\t45.70

    G5\t2.30\t2\t68.03

    G5\t2.30\t2\t69.19

    G5\t1.80\t2\t82.70

    G5\t2.00\t2\t92.76

    P4\t3.00\t2\t115.50

    Athlon64\t2.20\t1\t72.61

    P4\t3.30\t1\t84.22

    PentM\t1.70\t1\t96.08

    P4\t2.80\t1\t103.08

    P4\t2.40\t1\t109.89

    G5\t2.10\t1\t129.68

    G4\t1.50\t1\t183.35

    G4\t1.20\t1\t270.29

    G4\t1.00\t1\t274.47

    G3\t0.90\t1\t303.30

    G4\t0.70\t1\t408.87

    G4\t0.45\t1\t690.21



  • Reply 10 of 18
    Quad 2.5 x 4



    browser open on first 3 runs, closed on 4th



    1st run:



    Automatic Processor Detection found 4 processor cores.

    Playing 10000000 games across 4 cores...



    Thread# 0 created.

    Thread# 1 created.

    Thread# 2 created.

    Thread# 3 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 3335957 times

    Switcher has won 6664043 times

    Time elapsed for 10000000 solutions was 38.606123 seconds.



    2nd run



    Automatic Processor Detection found 4 processor cores.

    Playing 10000000 games across 4 cores...



    Thread# 0 created.

    Thread# 1 created.

    Thread# 2 created.

    Thread# 3 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 3333632 times

    Switcher has won 6666368 times

    Time elapsed for 10000000 solutions was 39.513698 seconds.



    3rd run



    Automatic Processor Detection found 4 processor cores.

    Playing 10000000 games across 4 cores...



    Thread# 0 created.

    Thread# 1 created.

    Thread# 2 created.

    Thread# 3 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 3334433 times

    Switcher has won 6665567 times

    Time elapsed for 10000000 solutions was 39.286804 seconds.





    4th run (quit browser first)



    Automatic Processor Detection found 4 processor cores.

    Playing 10000000 games across 4 cores...



    Thread# 0 created.

    Thread# 1 created.

    Thread# 2 created.

    Thread# 3 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 3332484 times

    Switcher has won 6667516 times

    Time elapsed for 10000000 solutions was 37.685298 seconds.
  • Reply 11 of 18
    Quote:

    Originally posted by finchna

    Quad 2.5 x 4



    Time elapsed for 10000000 solutions was 38.606123 seconds.



    Time elapsed for 10000000 solutions was 39.513698 seconds.



    Time elapsed for 10000000 solutions was 39.286804 seconds.



    Time elapsed for 10000000 solutions was 37.685298 seconds.




    Wow. My iMac kept up the pace!
  • Reply 12 of 18
    lundylundy Posts: 4,466member
    Quote:

    Originally posted by audiopollution

    Wow. My iMac kept up the pace!



    Amazing.



    Either the Cord Duo really is more than twice as fast as "teh G5", or the x86 binary of the Perl interpreter is hella more optimized than the PPC version.
  • Reply 13 of 18
    toweltowel Posts: 1,479member
    Quote:

    Originally posted by lundy

    Either the Cord Duo really is more than twice as fast as "teh G5", or the x86 binary of the Perl interpreter is hella more optimized than the PPC version.



    Either way, I need a mop for my drool. All my bioinformatics coding is in Perl. I can't wait to get my grubs on a MacBook Pro!
  • Reply 14 of 18
    vochvoch Posts: 28member
    And, just so we all feel good about ourselves, here's my TiBook 667/DVI.



    Automatic Processor Detection found 1 processor cores.

    Playing 10000000 games across 1 cores...



    Thread# 0 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 3333341 times

    Switcher has won 6666659 times

    Time elapsed for 10000000 solutions was 407.341591 seconds.
  • Reply 15 of 18
    Quote:

    Originally posted by Voch

    And, just so we all feel good about ourselves, here's my TiBook 667/DVI.



    Automatic Processor Detection found 1 processor cores.

    Playing 10000000 games across 1 cores...



    Thread# 0 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 3333341 times

    Switcher has won 6666659 times

    Time elapsed for 10000000 solutions was 407.341591 seconds.




    Ha! My iBook G3/800 kicked your TiBook's butt!



    Automatic Processor Detection found 1 processor cores.

    Playing 10000000 games across 1 cores...



    Thread# 0 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 3335244 times

    Switcher has won 6664756 times

    Time elapsed for 10000000 solutions was 303.443686 seconds.
  • Reply 16 of 18
    Another funny thing:



    Looks like finchna's Quad can play 3000 games in about the same time my iBook plays 2.



    Quote:

    Here's a quad result:



    Automatic Processor Detection found 4 processor cores.

    Playing 3000 games across 4 cores...



    Thread# 0 created.

    Thread# 1 created.

    Thread# 2 created.

    Thread# 3 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 993 times

    Switcher has won 2007 times

    Time elapsed for 3000 solutions was 0.040187 seconds.




    Automatic Processor Detection found 1 processor cores.

    Playing 2 games across 1 cores...



    Thread# 0 created.

    Waiting for thread(s) to finish....

    Grand totals for all threads:

    Sticker has won 0 times

    Switcher has won 2 times

    Time elapsed for 2 solutions was 0.037662 seconds.



    Times have changed, haven't they?
  • Reply 17 of 18
    toweltowel Posts: 1,479member
    iBook G3/600

    Playing 10000000 games across 1 cores...

    ...

    Time elapsed for 10000000 solutions was 403.873525 seconds.



    PM DP G4/1.42

    Playing 10000000 games across 2 cores...

    ...

    Time elapsed for 10000000 solutions was 106.837587 seconds.
  • Reply 18 of 18
    toweltowel Posts: 1,479member
    I had to dredge up this thread for my spankin'-new MBP 2.0:
    Quote:

    Automatic Processor Detection found 2 processor cores.

    Playing 10000000 games across 2 cores...

    Time elapsed for 10000000 solutions was 41.894183 seconds.

    ...

    Time elapsed for 10000000 solutions was 41.536525 seconds.




    Wow. Just wow.



    For fun, I tried running my main bioinfomatics Perl app on it. Same results - 2.5x faster per core/proc than my old workhorse, a 1.42GHz-G4. Oh man am I in love with this puppy.
Sign In or Register to comment.