Skip to content

Instantly share code, notes, and snippets.

@lpm11
Last active December 13, 2015 17:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lpm11/4945399 to your computer and use it in GitHub Desktop.
Save lpm11/4945399 to your computer and use it in GitHub Desktop.
Sexy-prime benchmark on Topaz vs. PyPy.

Sexy-prime benchmark on Topaz vs. PyPy

Also inspired by https://gist.github.com/havenwood/4724778. Sexy-prime ruby script can be found there.

Code @ Python

import time;

def is_prime(n):
    return all(n%i!=0 for i in range(2,n));

def sexy_primes(n):
    return filter(lambda x: all(is_prime(y) for y in x),[(i-6,i) for i in range(9,n)]);

a = time.time();
sexy_primes(100000);
b = time.time();

print(b - a);

Result

Note: Following time is result on rubbish machine, so result may varies.

  • Topaz (trunk): 19.18 sec
  • PyPy (1.9): 24.44 sec
  • Python (2.7.3): 308.45 sec
  • MRI-Ruby (1.9.3-p327): 309.95 sec

Misc

Another unscientific benchmark can be found at: https://gist.github.com/lpm11/4945388

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment