Skip to content

Instantly share code, notes, and snippets.

@paulwinex
Last active June 13, 2020 18:21
Show Gist options
  • Save paulwinex/739b4f43ffe8d1c6fabad982333ff6a7 to your computer and use it in GitHub Desktop.
Save paulwinex/739b4f43ffe8d1c6fabad982333ff6a7 to your computer and use it in GitHub Desktop.
import time
import os
def compute():
array = []
for i in range(10):
start = time.perf_counter()
for i in range(1000000):
x = 2*2
array.append(time.perf_counter() - start)
return sum(array) / len(array)
# start test 1
t1 = compute()
# change niceness
os.nice(19)
# Start test 2
t2 = compute()
# result
print("Test 1", t1, "sec")
print("Test 2", t2, "sec")
print("Diff", t2/t1, "times")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment