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:
parent
1695151267
commit
2a05f05f44
|
@ -0,0 +1,10 @@
|
|||
import bench
|
||||
|
||||
def func(a):
|
||||
pass
|
||||
|
||||
def test(num):
|
||||
for i in iter(range(num)):
|
||||
func(i)
|
||||
|
||||
bench.run(test)
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
|
@ -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)
|
Loading…
Reference in New Issue