mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-07-16 19:39:27 +00:00
Switch payload to 1000 bytes
This commit is contained in:
@@ -18,7 +18,7 @@ def get_random_bytes():
|
||||
log.debug("Connecting to RNG")
|
||||
connection = http.client.HTTPConnection("rng")
|
||||
log.debug("Sending request")
|
||||
connection.request("GET", "/4")
|
||||
connection.request("GET", "/1000")
|
||||
response = connection.getresponse()
|
||||
random_bytes = response.read()
|
||||
log.debug("Got {} bytes of random data".format(len(random_bytes)))
|
||||
@@ -37,6 +37,22 @@ def hash_bytes(data):
|
||||
return hex_hash
|
||||
|
||||
|
||||
def work_loop(interval=1):
|
||||
deadline = 0
|
||||
loops_done = 0
|
||||
old_total = 0
|
||||
while True:
|
||||
if time.time() > deadline:
|
||||
new_total = redis.incrby("hashes", loops_done)
|
||||
deadline = time.time() + interval
|
||||
loops_done = 0
|
||||
log.info("Current apparent speed: {}h/s"
|
||||
.format((new_total-old_total)/interval))
|
||||
old_total = new_total
|
||||
work_once()
|
||||
loops_done += 1
|
||||
|
||||
|
||||
def work_once():
|
||||
log.debug("Doing one unit of work")
|
||||
random_bytes = get_random_bytes()
|
||||
@@ -64,8 +80,5 @@ def work_once():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
while True:
|
||||
work_once()
|
||||
|
||||
|
||||
work_loop()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user