Limit running time by an ENV variable
parent
d6c9b22f7f
commit
05b1fadd6e
|
@ -1,4 +1,6 @@
|
||||||
import sys
|
import sys
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
def get_primes7(n):
|
def get_primes7(n):
|
||||||
"""
|
"""
|
||||||
|
@ -28,6 +30,9 @@ def get_primes7(n):
|
||||||
m = 2*i+3
|
m = 2*i+3
|
||||||
return [2]+[x for x in s if x]
|
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)
|
res = get_primes7(10000000)
|
||||||
print("Found {} prime numbers.".format(len(res)))
|
print("Found {} prime numbers.".format(len(res)))
|
||||||
|
|
Loading…
Reference in New Issue