Browse Source

Better pystone calculation

tags/2.3.5RC2
Sander Jo 7 years ago
committed by Safihre
parent
commit
02e18be5e1
  1. 28
      sabnzbd/utils/getperformance.py

28
sabnzbd/utils/getperformance.py

@ -40,15 +40,29 @@ def getcpu():
def getpystone(): def getpystone():
value = None # Iteratively find the pystone performance of the CPU
for pystonemodule in ['test.pystone', 'pystone']:
# Prefers using Python's standard pystones library, otherwise SABnzbd's pystones library
try:
# Try to import from the python standard library
from test.pystone import pystones
except:
try: try:
exec "from " + pystonemodule + " import pystones" # fallback: try to import from SABnzbd's library
value = int(pystones(1000)[1]) from pystone import pystones
break # import and calculation worked, so we're done. Get out of the for loop
except: except:
pass # ... the import went wrong, so continue in the for loop return None # no pystone library found
return value
# if we arrive here, we were able to succesfully import pystone, so start calculation
maxpystone = None
# Start with a short run, find the the pystone, and increase runtime until duration took > 0.1 second
for pyseed in [1000, 2000, 5000, 10000, 20000, 50000, 100000, 200000]:
duration, pystonefloat = pystones(pyseed)
maxpystone = max(maxpystone, int(pystonefloat))
# Stop when pystone() has been running for at least 0.1 second
if duration > 0.1:
break;
return maxpystone
if __name__ == '__main__': if __name__ == '__main__':

Loading…
Cancel
Save