Created
September 17, 2021 03:28
-
-
Save renpytom/c6edae881c843c99bd8bb99617ce6e98 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cPickle as pickle | |
import marshal | |
import time | |
data = { } | |
for i in range(1000000): | |
fn = intern('fn' + str(i // 1000)) | |
data[(fn, i // 1000, i)] = True | |
# Pickle. | |
if True: | |
times = [ ] | |
for reps in range(10): | |
start = time.clock() | |
pickle.dumps(data, pickle.HIGHEST_PROTOCOL) | |
times.append(time.clock() - start) | |
times.sort() | |
print("cPickle:") | |
print(" ".join("{:.4f}".format(t) for t in times)) | |
# Marshal. | |
if True: | |
times = [ ] | |
for reps in range(10): | |
start = time.clock() | |
marshal.dumps(data, 2) | |
times.append(time.clock() - start) | |
times.sort() | |
print("Marshal:") | |
print(" ".join("{:.4f}".format(t) for t in times)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment