diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-07 21:39:09 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-07 22:34:04 +0300 |
commit | 2a05f05f4468bc937e412e94df75da9dce9a6148 (patch) | |
tree | 72efdd3db3631a446124e32a32e8bdc528ee4511 /tests/bench | |
parent | 169515126784425df7b6fcd0a78ee5eb7dd84788 (diff) | |
download | micropython-2a05f05f4468bc937e412e94df75da9dce9a6148.tar.gz micropython-2a05f05f4468bc937e412e94df75da9dce9a6148.zip |
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.
Diffstat (limited to 'tests/bench')
-rw-r--r-- | tests/bench/func_args-1.1-pos_1.py | 10 | ||||
-rw-r--r-- | tests/bench/func_args-1.2-pos_3.py | 10 | ||||
-rw-r--r-- | tests/bench/func_args-2-pos_default_2_of_3.py | 10 | ||||
-rw-r--r-- | tests/bench/func_args-3.1-kw_1.py | 10 | ||||
-rw-r--r-- | tests/bench/func_args-3.2-kw_3.py | 10 |
5 files changed, 50 insertions, 0 deletions
diff --git a/tests/bench/func_args-1.1-pos_1.py b/tests/bench/func_args-1.1-pos_1.py new file mode 100644 index 0000000000..eee0ea8289 --- /dev/null +++ b/tests/bench/func_args-1.1-pos_1.py @@ -0,0 +1,10 @@ +import bench + +def func(a): + pass + +def test(num): + for i in iter(range(num)): + func(i) + +bench.run(test) diff --git a/tests/bench/func_args-1.2-pos_3.py b/tests/bench/func_args-1.2-pos_3.py new file mode 100644 index 0000000000..7e03ee2f85 --- /dev/null +++ b/tests/bench/func_args-1.2-pos_3.py @@ -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) diff --git a/tests/bench/func_args-2-pos_default_2_of_3.py b/tests/bench/func_args-2-pos_default_2_of_3.py new file mode 100644 index 0000000000..1fa0fbda59 --- /dev/null +++ b/tests/bench/func_args-2-pos_default_2_of_3.py @@ -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) diff --git a/tests/bench/func_args-3.1-kw_1.py b/tests/bench/func_args-3.1-kw_1.py new file mode 100644 index 0000000000..7bc81e5bea --- /dev/null +++ b/tests/bench/func_args-3.1-kw_1.py @@ -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) diff --git a/tests/bench/func_args-3.2-kw_3.py b/tests/bench/func_args-3.2-kw_3.py new file mode 100644 index 0000000000..7f95106841 --- /dev/null +++ b/tests/bench/func_args-3.2-kw_3.py @@ -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) |