-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeasure.py
54 lines (40 loc) · 1.11 KB
/
measure.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
"""Modul zum Messen von Laufzeiten"""
from time import time
import os
def join_uncorrectly(durchlauf):
"""Joinen mit arithmetischen Operatoren"""
f = open("strings.py", "a")
method = '"BLA" + '
string = ""
for i in range(durchlauf):
string += method
string += '"BLA"'
string = "test = " + string + "\n"
# string += "print(test)"
f.write(string)
f.close()
first_time = time()
os.system("python strings.py")
second_time = time()
os.remove("strings.py")
return second_time - first_time
def join_correctly(durchlauf):
"""Joinen mit join Funktion"""
f = open("strings.py", "a")
method = '"BLA", '
string = ""
for i in range(durchlauf):
string += method
string = '"".join((' + string + ' "BLA"))'
string = "test = " + string + "\n"
# string += "print(test)"
f.write(string)
f.close()
first_time = time()
os.system("python strings.py")
second_time = time()
os.remove("strings.py")
return second_time - first_time
if __name__ == "__main__":
join_uncorrectly(100)
join_correctly(100)