Skip to content

Instantly share code, notes, and snippets.

@gvalkov gvalkov/results.txt
Created Sep 6, 2012

Embed
What would you like to do?
$ /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
#!/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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.