public
Created

  • Download Gist
results.txt
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 102 103 104 105 106 107
$ /usr/bin/time --verbose python test.py py uint32
9.54168200493
Command being timed: "python test.py py uint32"
User time (seconds): 11.04
System time (seconds): 1.46
Percent of CPU this job got: 98%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:12.73
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 1581780
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 642581
Voluntary context switches: 1
Involuntary context switches: 1319
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
 
 
$ /usr/bin/time --verbose python test.py numpy uint32
2.85147213936
Command being timed: "python test.py numpy uint32"
User time (seconds): 4.55
System time (seconds): 1.29
Percent of CPU this job got: 97%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:05.97
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 1580980
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 229431
Voluntary context switches: 1
Involuntary context switches: 627
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
 
 
$ /usr/bin/time --verbose python test.py numpy uint64
8.09631299973
Command being timed: "python test.py numpy uint64"
User time (seconds): 8.94
System time (seconds): 2.18
Percent of CPU this job got: 98%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:11.29
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 2002840
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 232937
Voluntary context switches: 1
Involuntary context switches: 1153
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
 
 
# after removing all reference to numpy from test.py
/usr/bin/time --verbose pypy test.py
0.00810503959656
Command being timed: "pypy test.py"
User time (seconds): 0.21
System time (seconds): 0.03
Percent of CPU this job got: 97%
Elapsed (wall clock) time (h:mm:ss or m:ss): 0:00.25
Average shared text size (kbytes): 0
Average unshared data size (kbytes): 0
Average stack size (kbytes): 0
Average total size (kbytes): 0
Maximum resident set size (kbytes): 57072
Average resident set size (kbytes): 0
Major (requiring I/O) page faults: 0
Minor (reclaiming a frame) page faults: 14117
Voluntary context switches: 1
Involuntary context switches: 29
Swaps: 0
File system inputs: 0
File system outputs: 0
Socket messages sent: 0
Socket messages received: 0
Signals delivered: 0
Page size (bytes): 4096
Exit status: 0
test.py
Python
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
#!/usr/bin/env python
 
import timeit, sys
from numpy import arange, roll, column_stack, uint32, uint64
 
n = 6000
intsize = globals()[sys.argv[2]]
 
values_array = arange(0, 36000000, dtype=intsize)
values_list = range(0, 36000000)
 
def reshape_numpy():
idx = roll(arange(0, values_array.size, n), -1)
column_stack( (values_array.reshape(n, -1), values_array[idx]) )
 
def reshape_py():
splitlists = [values_list[i:i+n] for i in range(0, len(values_list), n-1)]
splitlists[-1].append(splitlists[0][0])
 
if sys.argv[1] == 'numpy':
t = timeit.Timer(stmt=reshape_numpy)
elif sys.argv[1] == 'py':
t = timeit.Timer(stmt=reshape_py)
 
print(t.timeit(10))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.