Skip to content

Instantly share code, notes, and snippets.

@davidohana
Last active November 2, 2020 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davidohana/641b1aa461d19fd8dbd00069008f4817 to your computer and use it in GitHub Desktop.
Save davidohana/641b1aa461d19fd8dbd00069008f4817 to your computer and use it in GitHub Desktop.
import hashlib
import math
import os
import random
from simple_profiler import SimpleProfiler
print("app started")
profiler = SimpleProfiler(reset_after_sample_count=200000)
profiler.start_section("init")
payload = os.urandom(10000)
r = random.random()
profiler.end_section()
while True:
profiler.start_section("total")
profiler.start_section("hashing")
profiler.start_section("md5")
hashlib.md5(payload)
profiler.end_section()
profiler.start_section("sha1")
hashlib.sha1(payload)
profiler.end_section()
profiler.start_section("sha256")
hashlib.sha256(payload)
profiler.end_section()
profiler.end_section("hashing")
profiler.start_section("random")
rand_number = random.random() * 1000000 + 1
profiler.end_section("random")
profiler.start_section("sqrt")
math.sqrt(rand_number)
profiler.end_section()
profiler.end_section("total")
if profiler.report(10):
print("-------")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment