-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_refresh_rate.py
47 lines (35 loc) · 1.16 KB
/
test_refresh_rate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import random
import subprocess
import time
CMD = 'xrandr --output DVI-D-0 --mode 1920x1080 --rate {rate}'
COUNT = 10
RATES = [60, 120]
def get_counts(total_rates, count):
base = count / total_rates
remainder = count - base * total_rates
counts = [base] * total_rates
for i in range(remainder):
counts[i] += 1
random.shuffle(counts)
return counts
def run_test():
rates = []
for rate, count in zip(RATES, get_counts(len(RATES), COUNT)):
for i in range(count):
rates.append(rate)
random.shuffle(rates)
raw_input('Starting test, press anything to continue...')
guesses = []
for rate in rates:
print 'Changing in 3 seconds...'
time.sleep(3)
subprocess.check_output(CMD.format(rate=rate), shell=True)
guesses.append(int(raw_input('Current rate: ')))
matches = [guesses[i] == rates[i] for i in range(len(rates))]
right_count = len([match for match in matches if match])
print 'Actual rates:', rates
print 'Guesses: ', guesses
print '{} guessed right out of {}'.format(right_count, len(rates))
return rates
if __name__ == '__main__':
run_test()