-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbench-console.py
111 lines (88 loc) · 2.05 KB
/
bench-console.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
from decimal import *
import time
import shutil
import zipfile
#config
RUN_TIME = 60;
default_b1 = 626;
default_b2 = 19550516;
default_b3 = 7214769;
default_b4 = 33477349;
default_b5 = 4867;
k_1 = Decimal(1) / Decimal(default_b1);
k_2 = Decimal(0.3) / Decimal(default_b2);
k_3 = Decimal(5) / Decimal(default_b3);
k_4 = Decimal(3) / Decimal(default_b4);
k_5 = Decimal(0.7) / Decimal(default_b5);
res_1 = 0;
res_2 = 0;
res_3 = 0;
res_4 = 0;
res_5 = 0;
#1
def copy_files():
time_end = time.time() + RUN_TIME;
count = 0;
while True:
count += 1;
shutil.copyfile(r'files/image.jpg', r'temp/image.jpg');
if (time.time() >= time_end):
return count;
#2
def find_hash(file):
time_end = time.time() + RUN_TIME;
count = 0;
while True:
with open(file, 'r') as read_file:
for line in read_file:
new_line = line.strip('\n')
count += 1;
if (time.time() >= time_end):
return count;
#3
def test_integer():
time_end = time.time() + RUN_TIME;
count = 0;
b = 0;
while True:
count += 1;
b += 22226545*22+26216*222+88**88*88;
if (time.time() >= time_end):
return count;
#4
def test_float():
time_end = time.time() + RUN_TIME;
count = 0;
b = 0.1;
while True:
count += 1;
b += 0.01;
if (time.time() >= time_end):
return count;
#5
def create_archive():
time_end = time.time() + RUN_TIME;
count = 0;
while True:
count += 1;
newzip=zipfile.ZipFile(r'temp/images.zip','w');
newzip.write(r'files/image.jpg');
if (time.time() >= time_end):
return count;
r1 = copy_files();
print(r1);
r2 = find_hash('files/PRO_WPA.txt');
print(r2);
r3 = test_integer();
print(r3);
r4 = test_float();
print(r4);
r5 = create_archive();
print(r5);
calc_1 = r1 * k_1;
calc_2 = r2 * k_2;
calc_3 = r3 * k_3;
calc_4 = r4 * k_4;
calc_5 = r5 * k_5;
result = calc_1 + calc_2 + calc_3 + calc_4 + calc_5;
print('%.1f' % result)