PY
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
"""
It's designed to compare the efficiency of different methods for summing a large number of integers
"""
import time
import numpy as np
from array import array
x = time.time()
print(x)
array_sum = np.sum(np.arange(1000000))
y = time.time()
print(y)
c = y-x
print(array_sum,"\n",c)
x= time.time()
sa = sum(array('i', range(1000000)))
y = time.time()
print(sa,"\n",y," ",x)
a = y-x
print(a)
x= time.time()
sl = sum(list(range(1000000)))
y = time.time()
print(sl,"\n",y," ",x)
b = y-x
print(b)
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run