Limit running time by an ENV variable

master
Ivan Zahariev 2016-09-08 17:50:42 +03:00
parent d6c9b22f7f
commit 05b1fadd6e
1 changed files with 6 additions and 1 deletions

View File

@ -1,4 +1,6 @@
import sys
import time
import os
def get_primes7(n):
"""
@ -28,6 +30,9 @@ def get_primes7(n):
m = 2*i+3
return [2]+[x for x in s if x]
while True:
startTime = int(time.time())
periodTime = int(os.environ['RUN_TIME'])
while (int(time.time()) - startTime) < periodTime:
res = get_primes7(10000000)
print("Found {} prime numbers.".format(len(res)))