Last visit was: It is currently Fri Mar 29, 2024 7:19 am


All times are UTC-05:00




Post new topic Reply to topic  [75 posts ] 
Author Message
 Post subject:Re: Programming Language Performance
PostPosted:Mon Nov 17, 2008 8:55 am 
User avatar
 

Joined:Mon Sep 22, 2008 9:51 am
Posts:112
Quote:
Um, what? From what I can tell, all of isPrime is there. Unless I'm reading his loop wrong...
Both of these are Lua

His isprime
Code:
function isPrime(num) if(num == 2) then return true end if(num % 2 == 0) then return false end limit = math.sqrt ( num ) + 1 for div = 3,limit,2 do if(num % div == 0) then return false end end return true end
My isprime
Code:
function isprime(x) if x < 2 then return false end if x < 4 then return true end if x == 5 then return true end if x % 2 == 0 then return false end if x % 5 == 0 then return false end if (x + 1) % 6 ~= 0 then if (x - 1) % 6 ~= 0 then return false end end local lim = math.sqrt(x) + 1.0 for y=3,lim,2 do if x % y == 0 then return false end end return true end

_________________
Oh this and that.


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Mon Nov 17, 2008 9:40 am 
Literally Nine
User avatar
 

Joined:Sat Apr 02, 2005 3:31 pm
Posts:1171
Location:The vicinity of an area adjacent to a location.
Here are the LuaJIT results on the "official" test machine:
Code:
Alcarin:genprime steven$ sudo nice -n -20 ./genprime-c 250000 1000000 Found 250000 primes in 2.00835 seconds (last was 3497861) Found 500000 primes in 5.58304 seconds (last was 7368787) Found 750000 primes in 10.18521 seconds (last was 11381621) Found 1000000 primes in 15.63836 seconds (last was 15485863) Alcarin:genprime steven$ sudo nice -n -20 luajit -O3 genprime.lua 250000 1000000 Found 250000 primes in 2.545365 seconds (last was 3497861) Found 500000 primes in 7.15543 seconds (last was 7368787) Found 750000 primes in 13.185175 seconds (last was 11381621) Found 1000000 primes in 20.308603 seconds (last was 15485863) Alcarin:genprime steven$
I used Chase's Lua code for this, because the isPrime function in the other one was weaksauce.

_________________
- Tycho

Image


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Mon Nov 17, 2008 10:37 am 
User avatar
 

Joined:Mon Sep 22, 2008 9:51 am
Posts:112
I used -O2, can I see the times without any optimization flag?

But in any case, it makes Lua with LuaJIT the fastest scripting language we have available. Even faster then the JIT Javascript. Which is good considering how many games it is used in.

Except that its not, http://shootout.alioth.debian.org/ .

_________________
Oh this and that.


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Tue Nov 18, 2008 3:02 pm 
User avatar
 

Joined:Sat Jun 03, 2006 3:51 am
Posts:1186
Website:http://griffinhart.livejournal.com/
Yahoo Messenger:Squall591
AOL:FinalWarrior591
Location:Look at my horse, my horse is amazing!
Quote:
I used Chase's Lua code for this, because the isPrime function in the other one was weaksauce.
Huh. Well, the "weaksauce" isPrime function is the one from the Ferrous Moon wiki: http://www.ferrousmoon.com/wiki/index.p ... ime_Test_3.
Code:
bool isPrime ( int _number ) { if ( _number == 2 ) return true; if ( _number % 2 == 0 ) return false; int limit = (int)sqrt ( (double)_number ) + 1; for ( int div = 3; div < limit; div += 2 ) { if ( _number % div == 0 ) return false; } return true; }
-- Griffinhart

_________________
"My word is my honor. My honor is my life."
-- Demonchild, Angelkin, the Blackest Seraph, the Final Warrior

Image


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Tue Nov 18, 2008 7:27 pm 
User avatar
 

Joined:Mon Sep 22, 2008 9:51 am
Posts:112
Those are out of date.

_________________
Oh this and that.


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Tue Nov 18, 2008 9:24 pm 
Literally Nine
User avatar
 

Joined:Sat Apr 02, 2005 3:31 pm
Posts:1171
Location:The vicinity of an area adjacent to a location.
The one from the Wiki is ancient, and was mainly used as a mere sample of how to optimize by finding the right algorithm.

_________________
- Tycho

Image


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Tue Nov 18, 2008 10:30 pm 
User avatar
 

Joined:Sat Jun 03, 2006 3:51 am
Posts:1186
Website:http://griffinhart.livejournal.com/
Yahoo Messenger:Squall591
AOL:FinalWarrior591
Location:Look at my horse, my horse is amazing!
Ah, i c. Well, that was the code I provided him (I was interested in what his vaunted Lua was capable of), as I couldn't find any other viable GenPrime sauces.

-- Griffinhart

_________________
"My word is my honor. My honor is my life."
-- Demonchild, Angelkin, the Blackest Seraph, the Final Warrior

Image


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Wed Nov 19, 2008 11:47 am 
Literally Nine
User avatar
 

Joined:Sat Apr 02, 2005 3:31 pm
Posts:1171
Location:The vicinity of an area adjacent to a location.
How about the Git repo?

_________________
- Tycho

Image


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Wed Dec 10, 2008 12:00 am 
Literally Nine
User avatar
 

Joined:Sat Apr 02, 2005 3:31 pm
Posts:1171
Location:The vicinity of an area adjacent to a location.
Okay, I've gathered the latest results, added Python 3.0, and a couple others:
Code:
genprime (C GCC) Found 250000 primes in 1.94566 seconds (last was 3497861) Found 500000 primes in 5.40500 seconds (last was 7368787) Found 750000 primes in 9.82264 seconds (last was 11381621) Found 1000000 primes in 15.08938 seconds (last was 15485863) genprime (C LLVM) Found 250000 primes in 1.98696 seconds (last was 3497861) Found 500000 primes in 5.52301 seconds (last was 7368787) Found 750000 primes in 10.04111 seconds (last was 11381621) Found 1000000 primes in 15.35083 seconds (last was 15485863) genprime (C LLVM JIT) Found 250000 primes in 1.97311 seconds (last was 3497861) Found 500000 primes in 5.48266 seconds (last was 7368787) Found 750000 primes in 10.00144 seconds (last was 11381621) Found 1000000 primes in 15.34265 seconds (last was 15485863) genprime (C Clang/LLVM) Found 250000 primes in 1.93325 seconds (last was 3497861) Found 500000 primes in 5.37139 seconds (last was 7368787) Found 750000 primes in 9.81430 seconds (last was 11381621) Found 1000000 primes in 15.02909 seconds (last was 15485863) genprime (C Clang/LLVM JIT) Found 250000 primes in 2.01441 seconds (last was 3497861) Found 500000 primes in 5.59148 seconds (last was 7368787) Found 750000 primes in 10.20508 seconds (last was 11381621) Found 1000000 primes in 15.65934 seconds (last was 15485863) genprime (C Intel Compiler) Found 250000 primes in 3.17819 seconds (last was 3497861) Found 500000 primes in 9.09660 seconds (last was 7368787) Found 750000 primes in 16.82925 seconds (last was 11381621) Found 1000000 primes in 26.01697 seconds (last was 15485863) genprime (C++) Found 250000 primes in 1.93410 seconds (last was 3497861) Found 500000 primes in 5.37282 seconds (last was 7368787) Found 750000 primes in 9.80067 seconds (last was 11381621) Found 1000000 primes in 15.03242 seconds (last was 15485863) genprime (C#) Found 250000 primes in 10.71136 seconds (last was 3497861) Found 500000 primes in 40.98805 seconds (last was 7368787) Found 750000 primes in 97.15990 seconds (last was 11381621) Found 1000000 primes in 183.22037 seconds (last was 15485863) genprime (Java) Found 250000 primes in 7.97291 seconds (last was 3497861) Found 500000 primes in 22.50499 seconds (last was 7368787) Found 750000 primes in 41.33362 seconds (last was 11381621) Found 1000000 primes in 63.83867 seconds (last was 15485863) genprime (Lua) Found 250000 primes in 17.20896 seconds (last was 3497861) Found 500000 primes in 48.28960 seconds (last was 7368787) Found 750000 primes in 88.40484 seconds (last was 11381621) Found 1000000 primes in 136.33394 seconds (last was 15485863) genprime (LuaJIT) Found 250000 primes in 2.69775 seconds (last was 3497861) Found 500000 primes in 7.49562 seconds (last was 7368787) Found 750000 primes in 13.67238 seconds (last was 11381621) Found 1000000 primes in 21.01764 seconds (last was 15485863) genprime (Objective-C) Found 250000 primes in 2.02039 seconds (last was 3497861) Found 500000 primes in 5.59195 seconds (last was 7368787) Found 750000 primes in 10.22687 seconds (last was 11381621) Found 1000000 primes in 15.69897 seconds (last was 15485863) genprime (Perl) Found 250000 primes in 56.56371 seconds (last was 3497861) Found 500000 primes in 156.72391 seconds (last was 7368787) Found 750000 primes in 283.23712 seconds (last was 11381621) Found 1000000 primes in 437.29664 seconds (last was 15485863) genprime (PHP) Found 250000 primes in 44.57772 seconds (last was 3497861) Found 500000 primes in 124.17359 seconds (last was 7368787) Found 750000 primes in 226.58663 seconds (last was 11381621) Found 1000000 primes in 348.99988 seconds (last was 15485863) genprime (Python 2.5) Found 250000 primes in 53.04501 seconds (last was 3497861) Found 500000 primes in 150.67896 seconds (last was 7368787) Found 750000 primes in 279.99946 seconds (last was 11381621) Found 1000000 primes in 432.82021 seconds (last was 15485863) genprime (Python 3.0) Found 250000 primes in 62.09792 seconds (last was 3497861) Found 500000 primes in 174.65253 seconds (last was 7368787) Found 750000 primes in 325.84933 seconds (last was 11381621) Found 1000000 primes in 498.66281 seconds (last was 15485863) genprime (Ruby) Found 250000 primes in 126.41413 seconds (last was 3497861) Found 500000 primes in 355.01142 seconds (last was 7368787) Found 750000 primes in 654.48230 seconds (last was 11381621) Found 1000000 primes in 1019.23751 seconds (last was 15485863)
And here are the interpreter/compiler versions:
Code:
gmcs --version Mono C# compiler version 2.0.1.0 mono --version Mono JIT compiler version 2.0.1 (tarball) Copyright (C) 2002-2008 Novell, Inc and Contributors. www.mono-project.com TLS: normal GC: Included Boehm (with typed GC) SIGSEGV: normal Notification: Thread + polling Architecture: x86 Disabled: none gcc -v Using built-in specs. Target: i686-apple-darwin9 Configured with: /var/tmp/gcc/gcc-5488~2/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9 Thread model: posix gcc version 4.0.1 (Apple Inc. build 5488) g++ -v Using built-in specs. Target: i686-apple-darwin9 Configured with: /var/tmp/gcc/gcc-5488~2/src/configure --disable-checking -enable-werror --prefix=/usr --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-transform-name=/^[cg][^.-]*$/s/$/-4.0/ --with-gxx-include-dir=/include/c++/4.0.0 --with-slibdir=/usr/lib --build=i686-apple-darwin9 --with-arch=apple --with-tune=generic --host=i686-apple-darwin9 --target=i686-apple-darwin9 Thread model: posix gcc version 4.0.1 (Apple Inc. build 5488) icc -v Version 11.0 java -version java version "1.5.0_16" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284) Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing) llc -version Low Level Virtual Machine (http://llvm.org/): llvm version 2.5svn Optimized build with assertions. make: [version] Error 1 (ignored) llvm-gcc -v Using built-in specs. Target: i386-apple-darwin9.5.0 Configured with: ../llvm-gcc/configure --prefix=/opt/llvm --enable-llvm=/Users/steven/Development/llvm/llvm --enable-languages=c,c++ --with-gmp=/opt/local --with-mpfr=/opt/local --program-prefix=llvm- --without-iconv Thread model: posix gcc version 4.2.1 (Based on Apple Inc. build 5628) (LLVM build) lua -v Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio luajit -v Lua 5.1.4 Copyright (C) 1994-2008 Lua.org, PUC-Rio LuaJIT 1.1.5 Copyright (C) 2005-2008 Mike Pall, http://luajit.org/ perl -v | grep built\ for This is perl, v5.8.8 built for darwin-2level php --version PHP 5.2.6 (cli) (built: Jul 17 2008 23:04:49) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies python2.5 --version Python 2.5.1 python3.0 --version Python 3.0 ruby --version ruby 1.8.6 (2008-03-03 patchlevel 114) [universal-darwin9.0]

_________________
- Tycho

Image


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Wed Dec 10, 2008 12:45 am 
Organ Donor
User avatar
 

Joined:Mon Aug 13, 2007 1:47 pm
Posts:529
Location:Jawjuh
Why would Python 3.0 be slower than 2.5? That's pretty backwards.

_________________
Creative people must be stopped! (Latest Entry 7/31/11: "Fishsticks (18+))

Pleasantville by Night, a humorous horror web RPG


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Wed Dec 10, 2008 1:13 am 
User avatar
 

Joined:Sat Jun 03, 2006 3:51 am
Posts:1186
Website:http://griffinhart.livejournal.com/
Yahoo Messenger:Squall591
AOL:FinalWarrior591
Location:Look at my horse, my horse is amazing!
Poor Tycho. Did you actually have to sit around for nearly 17 minutes, waiting for Ruby to generate one million prime numbers?

-- Griffinhart

_________________
"My word is my honor. My honor is my life."
-- Demonchild, Angelkin, the Blackest Seraph, the Final Warrior

Image


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Wed Dec 10, 2008 1:34 am 
Literally Nine
User avatar
 

Joined:Sat Apr 02, 2005 3:31 pm
Posts:1171
Location:The vicinity of an area adjacent to a location.
I took a nap, actually.

_________________
- Tycho

Image


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Wed Dec 10, 2008 1:35 am 
Literally Nine
User avatar
 

Joined:Tue Mar 01, 2005 9:00 am
Posts:1263
It was a LONG nap.


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Wed Dec 10, 2008 1:35 am 
Literally Nine
User avatar
 

Joined:Sat Apr 02, 2005 3:31 pm
Posts:1171
Location:The vicinity of an area adjacent to a location.
What can I say? Ruby takes a while.

_________________
- Tycho

Image


Top
Offline  
 Post subject:Re: Programming Language Performance
PostPosted:Wed Dec 10, 2008 1:36 am 
Literally Nine
User avatar
 

Joined:Tue Mar 01, 2005 9:00 am
Posts:1263
It was a four hour nap!


Top
Offline  
Display posts from previous: Sort by 
Post new topic Reply to topic

All times are UTC-05:00


Who is online

Users browsing this forum: No registered users and 19 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created by Miah with assistance from hyprnova