Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- import time
- def sozdanie(a):
- file_test = open("file.txt", "w")
- for i in range(a):
- number = randint(0,10000)
- file_test.write(str(number) + '\n')
- file_test.close()
- return 0
- def vstavka(list):
- p = 0
- for i in range(len(list)):
- j = i-1
- key = list[i]
- while list[j] > key and j >= 0:
- list[j+1] = list[j]
- j -= 1
- list[j+1] = key
- if (i%1000) == 0:
- p += 10
- print(p, "%")
- return(list)
- def chtenie(a):
- p = 0
- count = 0
- with open("file.txt") as f:
- for line in f:
- a.append([int(x) for x in line.split()])
- count += 1
- if (count%1000) == 0:
- p += 10
- print(p, "%")
- return(a)
- def schet(list):
- sum = 0
- sr = 0
- p = 0
- for i in range(10000-1):
- sum += int(data1[i])
- sr = sum / (1+i)
- if (i%1000) == 0:
- p += 10
- print(p, "%")
- return(sum, sr)
- def tablichka(a, b, c, d):
- x = ' '
- print('{0}'.format('Name'), (8*x), ' {0} {1} {2}'.format('PC1', 'PC2', 'Your PC'), '\n')
- print('{0}'.format('Calculating'),(x), '{0} {1} {2:.2f}'.format('18563.53' , '19152.91' , a), '\n')
- print('{0}'.format('Memory'),(6*x), '{0} {1} {2:.2f}'.format('29942.14' , '31473.45' , b), '\n')
- print('{0}'.format('Graphics'),(4*x), '{0} {1} {2:.2f}'.format('18475.39' , '17656.24', c), '\n')
- print('{0}'.format('Result'),(6*x), '{0} {1} {2:.2f}'.format('22327.02' , '22760.53', d), '\n')
- return 0
- #sozdanie(10000)
- data = []
- data1 = []
- print("Hello, it`s time to start benchmark")
- start_chtenie = time.time()
- chtenie(data)
- stop_chtenie = time.time()
- s_c = (stop_chtenie-start_chtenie)*300000
- print("prochital, otcenka graphic - ", s_c)
- start_sortirovka = time.time()
- vstavka(data)
- stop_sortirovka = time.time()
- s_v = (stop_sortirovka-start_sortirovka)*1000
- print("otsortiroval, otcenka memory - ", s_v)
- for row in data:
- data1.append(' '.join(map(str, row)))
- start_schet = time.time()
- sum, sr = schet(data1)
- stop_schet = time.time()
- s_s = (stop_schet-start_schet)*900000
- print("poschital, otcenka calculating - ", s_s)
- print("itogoviy resultat - ", ((s_c + s_v + s_s)/3), '\n')
- tablichka(s_s, s_c, s_v, ((s_c + s_v + s_s)/3))
Advertisement
Add Comment
Please, Sign In to add comment