Test Your New Mac Pro (and others) with this

Posted:
in Current Mac Hardware edited January 2014
OK folks, I dug up the "Auto Threaded Monty Hall Problem" Perl script.



This app will auto-detect and use as many processors as are on your machine and play the Monty Hall Dilemma to prove that switching doors is twice as good as not switching doors.



(See http://en.wikipedia.org/wiki/Monty_hall_problem for explanation).



INSTRUCTIONS:



1) Click the link to download the Perl script.

2) Unzip it if it doesn't automatically do that.

3) Save it somewhere, most conveniently on the desktop.

4) Go into Terminal and type (assuming the Perl script is on the desktop)



cd ~/Desktop

./OSXAutoThreadMHP.pl





You should see the results of playing 3000 games (the default) and the number of processors that the script auto-detected on your machine. Note the time elapsed and the fact that switching doors does win twice as often as not switching doors.



Now, to change the number of games (I advise in the millions if you have a fast machine), put the flag "-i" followed by a space followed by the number of games (iterations) you want the simulator to play. EXAMPLE:



./OSXAutoThreadMHP.pl -i 10000000



To play ten million games. For a quad, the script will assign 2.5 million games to each processor core.



Post your results!!!!



Here is the script. Let me know if there is a problem with corruption in the upload process. Zipped should work, but you never know. I can make it a disk image if needed.



Attachment 119

 

 
«13

Comments

  • Reply 1 of 48
    Mikes-Mac:~ mike$ /Users/mike/Documents/Downloads/OSXAutoThreadMHP.pl -i 10000000



    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 3334647 times

    Switcher has won 6665353 times

    Time elapsed for 10000000 solutions was 23.769091 seconds.



    edit: Stock dual 2.66GHz 1MB ram
  • Reply 2 of 48
    lundylundy Posts: 4,466member
    For comparison, here is my Dual 2.0 rev A G5:



    Dual-G5:~/Desktop lundy$ ./OSXAutoThreadMHP.pl -i 10000000



    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 3330883 times

    Switcher has won 6669117 times

    Time elapsed for 10000000 solutions was 80.993978 seconds.





    If you want to play with the threading, you can add the "-c" switch (for "cores") to make it use whatever number of cores you want. It should pretty much scale linearly with the number of cores you let it use.



    EXAMPLE:



    ./OSXAutoThreadMHP.pl -i 10000000 -c 2



    to use only 2 of your 4 cores.
  • Reply 3 of 48
    Mikes-Mac:~ mike$ /Users/mike/Documents/Downloads/OSXAutoThreadMHP.pl -i 10000000 -c 2



    Automatic Processor Detection found 4 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 3333651 times

    Switcher has won 6666349 times

    Time elapsed for 10000000 solutions was 35.821350 seconds.



    Hmm, not quite what I expected. I was expecting around 46 seconds.
  • Reply 4 of 48
    lundylundy Posts: 4,466member
    Interesting. Thread management overhead in Perl comes to mind. Lemme scrounge up the C program I have somewhere...
  • Reply 5 of 48
    lundylundy Posts: 4,466member
    Here is a Universal Binary of an auto-threading C application that computes the factorial of 6 -- 50 million times. To execute it,



    ./Threaded\\ Factorial numcores numiterations



    Both arguments are optional - but if you want to specify the iterations, you have to put the # of cores also.



    EXAMPLES:



    ./Threaded\\ Factorial

    Produces 50 million iterations and auto-detects the number of cores.



    ./Threaded\\ Factorial 2 1000000

    Produces 10 million on 2 threads.



    ./Threaded\\ Factorial 2

    Produces 50 million on 2 threads.



    The Universal Binary:

    Attachment 120

     

     
  • Reply 6 of 48
    2 processors detected in system.



    50000000 total iterations will be performed.

    Starting to create 2 threads.



    Creating Thread Number: 0

    Creating Thread Number: 1



    Loop Done; Time=4 secs for thread#:0, Loops=25000000

    Loop Done; Time=4 secs for thread#:1, Loops=25000000

    logout

    [Process completed]



    Eh?
  • Reply 7 of 48
    lundylundy Posts: 4,466member
    What computer?



    Also it appears you double-clicked the executable - that is why it opened Terminal and did a logout. No problem though.



    Give it 500 million for a reasonable result.
  • Reply 8 of 48
    tubgirltubgirl Posts: 177member
    Code:


    c83-248-56-109:~/downloads kenstarr$ ./OSXAutoThreadMHP.pl -i 10000000



    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 3332535 times

    Switcher has won 6667465 times

    Time elapsed for 10000000 solutions was 272.644690 seconds.





    dual G4@500MHz
  • Reply 9 of 48
    b3ns0nb3ns0n Posts: 95member
    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 3332509 times

    Switcher has won 6667491 times

    Time elapsed for 10000000 solutions was 107.359259 seconds.



    P4 3.07 GHz w/HT and 1.5 GB SDRAM
  • Reply 10 of 48
    axc51axc51 Posts: 98member
    MBP 2.16ghz, 2GB RAM, 100gb 7200rpm HD:



    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 3334219 times

    Switcher has won 6665781 times

    Time elapsed for 10000000 solutions was 37.867453 seconds.
  • Reply 11 of 48
    lundylundy Posts: 4,466member
    Anybody got a quad G5??



    I tell ya, that Yonah chip holds its own.
  • Reply 12 of 48
    Here's the threaded factorial test. I had to use 10,000,000,000 to get a decent result.

    Again, 2.66MHz woodcrest 1GB ram:





    Mikes-Mac:~ mike$ /Users/mike/Documents/Downloads/Threaded\\ Factorial 4 10000000000



    4 processors detected in system.



    2147483647 total iterations will be performed.

    Starting to create 4 threads.



    Creating Thread Number: 0

    Creating Thread Number: 1

    Creating Thread Number: 2

    Creating Thread Number: 3



    Loop Done; Time=35 secs for thread#:1, Loops=536870911

    Loop Done; Time=35 secs for thread#:3, Loops=536870911

    Loop Done; Time=35 secs for thread#:0, Loops=536870911

    Loop Done; Time=35 secs for thread#:2, Loops=536870911



    Edit:

    2 threads Time = 69 secs

    1 thread Time = 138 secs



    My wife's G4 466GHz 384MB ram: 1 Thread (obviously) Time = 1403 secs That's over 23 mins
  • Reply 13 of 48
    lundylundy Posts: 4,466member
    LOL - yeah you overflowed the signed integer there Bud.



    2 to the 31 power is the limit for signed 32-bit integer (2,147,483,647).



    I suppose I could make that unsigned integer -- then we would have 2 to the 32 to play with (4,294,967,296).



    I can't make it 64-bit as it would blow up on the 32-bit machines.
  • Reply 14 of 48
    backtomacbacktomac Posts: 4,579member
    Quote:
    Originally Posted by axc51


    MBP 2.16ghz, 2GB RAM, 100gb 7200rpm HD:



    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 3334219 times

    Switcher has won 6665781 times

    Time elapsed for 10000000 solutions was 37.867453 seconds.



    Damn fine showing for core duo. I don't know why I'm waiting for core 2.
  • Reply 15 of 48
    I've been trying for the past 10 minutes to run this on my 2.0 ghz MacBook, and for the life of my I cannot figure out how to run the script. I know, I know, I'm really dumb. Anybody want to help so that we may see how the MacBook fairs against the others?
  • Reply 16 of 48
    lundylundy Posts: 4,466member
    More detail please.



    What are you doing, what message if any do you get, etc. etc...
  • Reply 17 of 48
    Quote:
    Originally Posted by lundy


    More detail please.



    What are you doing, what message if any do you get, etc. etc...



    Ok, sorry. It says "maimezvous-computer:~ mhalsey$ cd ~/Desktop./OSXAutoThreadMHP.pl

    -bash: cd: /Users/maimezvous/Desktop./OSXAutoThreadMHP.pl: No such file or directory"



    I think I'm leaving something out, but I don't know. I've never used Terminal before. I unzipped the file and it's on the desktop. Other than that I don't know what else to tell you.
  • Reply 18 of 48
    lundylundy Posts: 4,466member
    You ran the two commands together. There is a "cd" command and a "./" (dotslash) command. Type each one and hit return at the end of each:



    cd ~/Desktop





    ./OSXAutoThreadMHP.pl
  • Reply 19 of 48
    Ok, I got it this time. Once again, sorry for my lack of knowledge. Anyway, here is the results for a 2.0ghz 2gb ram white MacBook:



    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 3331870 times

    Switcher has won 6668130 times

    Time elapsed for 10000000 solutions was 53.675986 seconds.



    Pretty good. Thanks for the help Lundy.
  • Reply 20 of 48
    lundylundy Posts: 4,466member
    One of the reasons that the Core Duo as well as the Woodcrest do so well on the factorial test is the 2MB of level 2 cache. The entire binary is only 40 KB - it can almost fit in level 1 cache. So the CPU doesn't have to go to RAM at all, unless you have other processes being switched in and out which are clobbering the cache.
Sign In or Register to comment.