Created
January 11, 2021 09:28
-
-
Save gsalgado/4a12e1b178232f74d1d1417bcfeedbf7 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 logging | |
import secrets | |
import time | |
import cloudpickle | |
from eth_utils import keccak | |
from trinity.components.builtin.peer_discovery import component | |
class Foo: | |
def __init__(self, arg): | |
self.arg = arg | |
async def do_run(self, d): | |
return None | |
d = Foo(None) | |
start = time.time() | |
for _ in range(1000): | |
cloudpickle.dumps(d.do_run) | |
print(f"Pickling instance method: {time.time() - start} seconds") | |
start = time.time() | |
for _ in range(1000): | |
cloudpickle.dumps(keccak) | |
print(f"Pickling keccak(): {time.time() - start} seconds") | |
data = secrets.token_bytes(256) | |
start = time.time() | |
for _ in range(1000): | |
cloudpickle.dumps(data) | |
print(f"Pickling 256 bytes of data: {time.time() - start} seconds") | |
data = secrets.token_bytes(1024 ** 2) | |
start = time.time() | |
for _ in range(1000): | |
cloudpickle.dumps(data) | |
print(f"Pickling 1MB of data: {time.time() - start} seconds") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment