|
#1
| ||||
| ||||
| Arg! Twice as slow as Pentium...
Argh! This is frustrating, and I wonder how much of it has to do with the way Objective-C messages are passed around in Cocoa: I have a random number generator (a good one with 10^57 cycle length!), and I timed how long it took to generate one billion random numbers between zero and one. On my work's 733 Mhz Pentium III with Yellow Box for Windows NT it took 6.8 minutes. On my PowerBook G4 with Mac OS X 10.0.4 it took 12.4 minutes. Where's all the extra slow-down coming from? Even if the chips' architectures were not major players, you'd only expect a 5/7 relationship in performance. No AltiVec can be used with the RNG's double and long calculations. Very odd. -Rob
__________________ There are only 10 kinds of people in the world: Those who understand binary, and those who don't. |
|
#2
| ||||
| ||||
|
Is the program a Command Line one, or is it a GUI. Do you think Aqua has anything to do with the performance hits? Maybe when 10.1 is released it will score better. |
|
#3
| ||||
| ||||
|
It's GUI. It consists of a button that says Go. Then there's a for loop that loops one billion times and generates random numbers. They're just generated--I don't even do anything with them. -Rob
__________________ There are only 10 kinds of people in the world: Those who understand binary, and those who don't. |
|
#4
| ||||
| ||||
|
This is an absolute stab in the dark. I'm not sure how the NT box would be generating random numbers, but in the very least my OpenBSD box reseeds an "entropy pool" with presumedly erratic data from network latency, serial inputs, system loads, etc. As OSX has some BSD roots (although I believed that was mostly in the network arena) is it possible that OSX is being slowed down because it's constantly refilling this entropy pool, and the NT box is just chucking out the numbers? Even if this were the case, you can agree this is a fairly narrow performance niche to fill hehehe. I can think of a thousand facts that would make this seem like a ridiculous idea, so I'll hush now. It was just a thought. -stephen |
|
#5
| ||||
| ||||
|
You know, that leads me to another thought... Might be that if you ran the program as root (different priority level) it would perform better. Have you benchmarked it on your desktop machine? Maybe it is a powerbook issue (slower clocks if using battary or something like that). |
|
#6
| ||||
| ||||
|
I'm not using the built-in RNG. It's a new one that's got much better properties and a much longer cycle length. It's processing consists of a bunch of addition and multiplication of doubles. The two programs are identical, both running under ProjectBuilder, one on Windows NT, one on Mac OS X. I could try running as root. Aside from the rumor that 'nice' and thread priorities aren't implemented, I'd be pretty upset to learn that I have to run code as root in order to get good performance! This is probably not it, though I'll give it a shot for troubleshooting's sake. It seems as if the Objective-C message-passing has way too much overhead on OS X. This is surprising, seeing that Cocoa has been around under other names for at least a decade (and has no problems as Yellow Box). These kinks should have been ironed out years ago, if in fact these "kinks" are what's causing the terrible performance. Still, one good lesson to take from this (which we all should have known anyway): Don't use Objective-C messages for performance-critical code. Sure, use it to construct your app and be a wrapper, but for heavy math and such, use C/C++ where the lower overhead is the more important trait. Cheers. -Rob
__________________ There are only 10 kinds of people in the world: Those who understand binary, and those who don't. |
|
#7
| ||||
| ||||
|
I decided to run a test myself using PHP rather than C [which is WAY slower by the way]. The problem with my test is that the 4 test machines are not all running the same versions of PHP. When I upgrade PHP on my G4, I will post the execution time decrease if any. Reatta: dual 733MHz PIII, 512MB RAM, PHP 4.0.6: Did nothing in 1.0672010183334 seconds Delorean: single 733MHz PIII, 256MB RAM, PHP 4.0.6: Did nothing in 1.0971649885178 seconds [PHP must NOT be multi threaded??] Immaculata: single 400MHz PII, 256MB RAM, PHP 4.0.5: Did nothing in 1.5302710533142 seconds Darklotus: Dual 500MHz G4, 1GB RAM, PHP 4.0.4pl1: Did nothing in 2.8723210096359 seconds Here is the code in case you would like to try it out: Code: <?
function getmicrotime(){
list($usec, $sec) = explode(" ",microtime());
return ((float)$usec + (float)$sec);
}
$time_start = getmicrotime();
for ($i=0; $i < 1000000; $i++){
//do nothing, 1000000 times
}
$time_end = getmicrotime();
$time = $time_end - $time_start;
echo "Did nothing in $time seconds";
?>
__________________ -Paul Wieland______________ http://www.sickdimension.com Dual G5 2.0Ghz / 2.5GB Ram / 620 GB HD / 23" CD |
|
#8
| ||||
| ||||
| An Idea...
rharder: you mentioned that you did nothing with the random numbers that you were generating. If you are going to wait minutes for the results, why don't you just SUM and average the random numbers. At the end of the loop, assuming you are generating numbers between 0 and 1, you should get an average of "0.5". Please post your results so we can see. |
![]() |
| Bookmarks |
| Thread Tools | |
|
|
| | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| internet connection really slow. please help! | kidxsai | Networking & Compatibility | 6 | February 27th, 2009 06:56 AM |
| really really slow speeds on a LAN.... | reverseswim | Networking & Compatibility | 7 | May 24th, 2003 11:38 AM |
| IE slow to respond in 10.1? Unresponsive? | djubelirer | Mac OS X System & Mac Software | 2 | October 5th, 2001 12:26 PM |
| OSX and iBook: slow forever? | soupandtea | Apple News, Rumors & Discussion | 4 | July 19th, 2001 03:53 PM |
| Why downloading is so slow compared to Windows??? | troydugger | Mac OS X System & Mac Software | 6 | May 27th, 2001 04:10 PM |