summaryrefslogtreecommitdiff
path: root/pct-speedtest.py
diff options
context:
space:
mode:
Diffstat (limited to 'pct-speedtest.py')
-rw-r--r--pct-speedtest.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/pct-speedtest.py b/pct-speedtest.py
index daed105..9763f09 100644
--- a/pct-speedtest.py
+++ b/pct-speedtest.py
@@ -30,11 +30,18 @@ import sys
from Crypto.PublicKey import RSA
from Crypto.Cipher import AES, ARC2, ARC4, Blowfish, CAST, DES3, DES, XOR
from Crypto.Hash import MD2, MD4, MD5, SHA256, SHA
+from Crypto.Random import get_random_bytes
try:
from Crypto.Hash import RIPEMD
except ImportError: # Some builds of PyCrypto don't have the RIPEMD module
RIPEMD = None
+# os.urandom() is less noisy when profiling, but it doesn't exist in Python < 2.4
+try:
+ urandom = os.urandom
+except AttributeError:
+ urandom = get_random_bytes
+
class Benchmark:
def __init__(self):
@@ -70,7 +77,7 @@ class Benchmark:
return self.__random_data
def _random_bytes(self, b):
- return os.urandom(b)
+ return urandom(b)
def announce_start(self, test_name):
sys.stdout.write("%s: " % (test_name,))