| Ferrous Moon http://www.ferrousmoon.com:80/forums/ |
|
| Programming Language Performance http://www.ferrousmoon.com:80/forums/viewtopic.php?f=45&t=1580 |
Page 2 of 5 |
| Author: | Chase [Fri Nov 14, 2008 1:12 pm ] |
| Post subject: | Re: Programming Language Performance |
I wrote a copy of it in Fortran 77 (similar), and here are the results, I used a stopwatch to make sure. I am just lucky seconds() returns a real. I never really did Fortran before so this was very educational for me. Fortran doesn't seem to have a fancy printf function, though there are ways to emulate it. I could of made the ouput prettier but really not required. Code: Q:\Tools\MinGW>bin\g77 --version
GNU Fortran (GCC) 3.4.5 (mingw-vista special r3)
Copyright (C) 2004 Free Software Foundation, Inc.
Q:\Tools\MinGW>bin\g77 -o genprime.exe genprime.f
Redid it using realtime pripority:
Code: Found 250000 primes in 5.078125 (last was 3497861)
Found 500000 primes in 13.921875 (last was 7368787)
Found 750000 primes in 25.359375 (last was 11381621)
Found 1000000 primes in 40.796875 (last was 15485863)
Here is the C version, being on windows it don't necessarily mean my system is twice as slow as Tycho's. Code: Found 250000 primes in 3.92188 seconds (last was 3497861)
Found 500000 primes in 10.95313 seconds (last was 7368787)
Found 750000 primes in 20.28125 seconds (last was 11381621)
Found 1000000 primes in 31.25000 seconds (last was 15485863)
Using these, I approximate Fortran to be Code: Found 250000 primes in 2.575114 (last was 3497861)
Found 500000 primes in 7.059774 (last was 7368787)
Found 750000 primes in 12.859723 (last was 11381621)
Found 1000000 primes in 20.688070 (last was 15485863)
|
|
| Author: | Tycho [Fri Nov 14, 2008 4:25 pm ] |
| Post subject: | Re: Programming Language Performance |
Can you fork GenPrime on GitHub, add the Fortran .f file, commit, push, and send me a pull request? |
|
| Author: | Chase [Fri Nov 14, 2008 6:09 pm ] |
| Post subject: | Re: Programming Language Performance |
To be completely honest I don't know how to use git. Though while I gave it a shot, I do not really want take the time to learn it at this time. If you want a copy of the file I left it on my server here: Get the file |
|
| Author: | eddieringle [Sat Nov 15, 2008 4:38 pm ] |
| Post subject: | Re: Programming Language Performance |
I've forked it myself and pushed it for you, Chase. I've also sent Tycho a pull-request. |
|
| Author: | Tycho [Sat Nov 15, 2008 5:05 pm ] |
| Post subject: | Re: Programming Language Performance |
The commit has been pulled, and the new code has been pushed to github. |
|
| Author: | FinalWarrior [Sat Nov 15, 2008 9:40 pm ] |
| Post subject: | Re: Programming Language Performance |
So, I showed this to a friend of mine - who champions Lua - and had him test Lua with GenPrime. His PC's specs are entirely different, of course, and he's not using pure Lua (he's using Löve, but says it shouldn't make too much of a difference). Here are his results: http://img32.picoodle.com/img/img32/3/1 ... 54e96d.png According to him, that's with a single core. -- Griffinhart |
|
| Author: | Chase [Sat Nov 15, 2008 11:16 pm ] |
| Post subject: | Re: Programming Language Performance |
Must have an error in the program then. |
|
| Author: | Miah [Sun Nov 16, 2008 12:15 am ] |
| Post subject: | Re: Programming Language Performance |
I'm going to agree with Chase on this one. Can we get the code? |
|
| Author: | FinalWarrior [Sun Nov 16, 2008 1:57 am ] |
| Post subject: | Re: Programming Language Performance |
Since I linked him to the FM wiki article on GenPrime, and he said he just rewrote it to fit Lua's syntax... I don't think it's an error. But again, I could be wrong. I'll bug him for the code and give it to you when I get it. -- Griffinhart |
|
| Author: | FinalWarrior [Sun Nov 16, 2008 6:12 pm ] |
| Post subject: | Re: Programming Language Performance |
K, here's the sauce: http://rafb.net/p/v8n2Be65.html Note that this isn't pure Lua; the "load and draw functions are called by Löve", according to my friend. -- Griffinhart |
|
| Author: | Chase [Sun Nov 16, 2008 6:58 pm ] |
| Post subject: | Re: Programming Language Performance |
A decent portion of the isprime function is missing. I am writing up a copy for the LuaJIT. |
|
| Author: | Chase [Sun Nov 16, 2008 8:02 pm ] |
| Post subject: | Re: Programming Language Performance |
Some impressive results (atleast on my system) for the LuaJIT. (Mind you not as impressive as the ones that FinalWarrior posted). Code: JuaJIT
Found 250000 primes in 3.343 seconds (last was 3497861)
Found 500000 primes in 9.422 seconds (last was 7368787)
Found 750000 primes in 17.297 seconds (last was 11381621)
Found 1000000 primes in 26.531 seconds (last was 15485863)
Lua
Found 250000 primes in 27.265 seconds (last was 3497861)
Found 500000 primes in 76.531 seconds (last was 7368787)
Found 750000 primes in 140.344 seconds (last was 11381621)
Found 1000000 primes in 218.047 seconds (last was 15485863)
I compiled the JIT on my computer, just for reference I ran the c version againCode: Found 250000 primes in 3.89063 seconds (last was 3497861)
Found 500000 primes in 11.18750 seconds (last was 7368787)
Found 750000 primes in 20.59375 seconds (last was 11381621)
Found 1000000 primes in 31.87500 seconds (last was 15485863)
Now either the time function in the Lua script is off (I somehow doupt this), or the LuaJIT version is faster then the C version on my system. However I find this somewhat possible if the LuaJIT makes certain platform specific optimizations that are not in the C version.Therefore I approximate the results to be Code: JuaJIT
Found 250000 primes in 1.662 seconds (last was 3497861)
Found 500000 primes in 4.683 seconds (last was 7368787)
Found 750000 primes in 8.598 seconds (last was 11381621)
Found 1000000 primes in 13.188 seconds (last was 15485863)
Lua
Found 250000 primes in 13.552 seconds (last was 3497861)
Found 500000 primes in 38.040 seconds (last was 7368787)
Found 750000 primes in 69.760 seconds (last was 11381621)
Found 1000000 primes in 108.383 seconds (last was 15485863)
I used the same lua script for both the LuaJIT and the default Lua. This just shows just how much JIT does help.You can download a copy of the script here: Get it here EDIT: I discoverd an extra layer of enablable optimization in the jit I got these results by turning it on. Code: LuaJIT
Found 250000 primes in 3.015 seconds (last was 3497861)
Found 500000 primes in 8.578 seconds (last was 7368787)
Found 750000 primes in 16 seconds (last was 11381621)
Found 1000000 primes in 24.532 seconds (last was 15485863)
Approximates to
Found 250000 primes in 1.499 seconds (last was 3497861)
Found 500000 primes in 4.264 seconds (last was 7368787)
Found 750000 primes in 7.953 seconds (last was 11381621)
Found 1000000 primes in 12.194 seconds (last was 15485863)
Here is a dump of the asm code it wrote for the optimized version: Get it here
|
|
| Author: | FinalWarrior [Sun Nov 16, 2008 8:46 pm ] |
| Post subject: | Re: Programming Language Performance |
Quote: A decent portion of the isprime function is missing.
Um, what? From what I can tell, all of isPrime is there. Unless I'm reading his loop wrong... (Mind you, I've only had a rudimentary walkthrough with Lua, so I'm not fluent in it.)-- Griffinhart ETA: And once again, he's got a different rig. I dun has his hardware specs, though (I'll bother him for those if you guys want me to). |
|
| Author: | Chase [Sun Nov 16, 2008 8:54 pm ] |
| Post subject: | Re: Programming Language Performance |
I can hardly believe the results myself. <_< EDIT: GAH, triple post. Delete this. |
|
| Author: | eddieringle [Mon Nov 17, 2008 6:32 am ] |
| Post subject: | Re: Programming Language Performance |
Quote: ETA: And once again, he's got a different rig. I dun has his hardware specs, though (I'll bother him for those if you guys want me to).
Yes, bothering is good. |
|
| Page 2 of 5 | All times are UTC-05:00 |
| Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |
|