tests/bench: Add tests for various ways to pass function args.

Passing 3 args with keywords is for example 50% slower than via positional
args.
This commit is contained in:
Paul Sokolovsky 2014-05-07 21:39:09 +03:00
parent 1695151267
commit 2a05f05f44
5 changed files with 50 additions and 0 deletions

View File

@ -0,0 +1,10 @@
import bench
def func(a):
pass
def test(num):
for i in iter(range(num)):
func(i)
bench.run(test)

View File

@ -0,0 +1,10 @@
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
func(i, i, i)
bench.run(test)

View File

@ -0,0 +1,10 @@
import bench
def func(a, b=1, c=2):
pass
def test(num):
for i in iter(range(num)):
func(i)
bench.run(test)

View File

@ -0,0 +1,10 @@
import bench
def func(a):
pass
def test(num):
for i in iter(range(num)):
func(a=i)
bench.run(test)

View File

@ -0,0 +1,10 @@
import bench
def func(a, b, c):
pass
def test(num):
for i in iter(range(num)):
func(c=i, b=i, a=i)
bench.run(test)