Skip to content

Instantly share code, notes, and snippets.

@stepancheg
Created November 21, 2018 03:34
Show Gist options
  • Save stepancheg/b321d8da7d4ee0a5822e258ed7fe543d to your computer and use it in GitHub Desktop.
Save stepancheg/b321d8da7d4ee0a5822e258ed7fe543d to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from __future__ import print_function
import time
s = ""
def f():
global s
s += "a"
t = time.time()
for i in xrange(1000000000):
f()
step = 100000
if i % step == 0:
print("{:.4}us".format((time.time() - t) / step * 1000000))
t = time.time()
# vim: set ts=4 sw=4 et:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment