Created
April 17, 2020 10:54
-
-
Save hackaugusto/8e99c58328d7d9e13f89b5ccc8080ca9 to your computer and use it in GitHub Desktop.
time response times for geth get logs requests.
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 gevent.monkey # isort:skip | |
gevent.monkey.patch_all() # isort:skip | |
import statistics | |
import time | |
import gevent | |
from web3 import HTTPProvider, Web3 | |
def do_request(): | |
web3 = Web3(HTTPProvider("http://geth.mainnet.ethnodes.brainbot.com:8545")) | |
to_block = web3.eth.blockNumber | |
from_block = to_block - 1 | |
before = time.time() | |
web3.manager.request_blocking("eth_getLogs", [{"fromBlock": from_block, "toBlock": to_block}]) | |
return time.time() - before | |
for qty in range(2, 1_000_000, 10): | |
requests = [gevent.spawn(do_request) for _ in range(qty)] | |
response_times = [g.get() for g in gevent.wait(requests)] | |
quantiles = list(statistics.quantiles(response_times, n=100)) | |
print(qty, quantiles[49], quantiles[89], quantiles[98], flush=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment