Commit 232d762c authored by Peter Steinbach's avatar Peter Steinbach

finished hacky hour

parent 32b0342b
......@@ -28,7 +28,7 @@ def inplace_sort(alist, n):
alist[:] = [ (x[n], x) for x in alist ]
alist.sort()
alist[:] = [ val for (key,val) in alist ]
return
def test_inplace_sort(benchmark, testlist):
......
from lorem_fixture import lorem
def list_of_uppercase(alist):
value = []
for item in alist:
value.append( item.upper() )
return value
def test_manual(benchmark,lorem):
res = benchmark(list_of_uppercase,lorem)
assert res[0] != lorem[0]
def map_uppercase(alist):
value = map(str.upper, alist)
return value
def test_map(benchmark,lorem):
res = benchmark(map_uppercase,lorem)
assert list(res)[0] != lorem[0]
def manual_with_locals(alist):
up = str.upper
value = []
append = value.append
for w in alist:
append(up(w))
return value
def test_with_locals(benchmark,lorem):
res = benchmark(manual_with_locals,lorem)
assert res[0] != lorem[0]
# def test_join(benchmark,lorem):
# res = benchmark(" ".join, lorem)
# assert res.startswith(" ".join(lorem))
def import_inside(name):
import string
return name+string.ascii_lowercase
def test_import_inside(benchmark):
res = benchmark(import_inside,"PYTHON has a lot of syntactic sugar!")
def test_import_outside(benchmark):
import string
def append(name):
return name+string.ascii_lowercase
res = benchmark(append,"PYTHON has a lot of syntactic sugar!")
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment