Test Your New Mac Pro (and others) with this
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
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
Comments
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
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.
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.
./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
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?
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.
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
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
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.
I tell ya, that Yonah chip holds its own.
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
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.
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.
What are you doing, what message if any do you get, etc. etc...
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.
cd ~/Desktop
./OSXAutoThreadMHP.pl
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.