diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-07 21:33:36 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-07 22:34:00 +0300 |
commit | 6638ea9ca37377a8136fb25f64f7c7710f641cd2 (patch) | |
tree | 005ad48d0bf538240df559710cd4b7cb53fab5b0 | |
parent | 52b25293e2bc7aa6828039c4535916f165031659 (diff) | |
download | micropython-6638ea9ca37377a8136fb25f64f7c7710f641cd2.tar.gz micropython-6638ea9ca37377a8136fb25f64f7c7710f641cd2.zip |
tests/bench: Add testcases for lookup in 5-el instance and namedtuple.
... and we have not that bad mapping type after all - lookup time is ~ the
same as in one-attr instance. My namedtuple implementation on the other
hand degrades awfully.
So, need to rework it. First observation is that named tuple fields are
accessed as attributes, so all names are interned at the program start.
Then, really should store field array as qstr[], and do quick 32/64 bit
scan thru it.
-rw-r--r-- | tests/bench/var-6.1-instance-attr-5.py | 18 | ||||
-rw-r--r-- | tests/bench/var-8.1-namedtuple-5th.py | 12 |
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/bench/var-6.1-instance-attr-5.py b/tests/bench/var-6.1-instance-attr-5.py new file mode 100644 index 0000000000..e8d3383605 --- /dev/null +++ b/tests/bench/var-6.1-instance-attr-5.py @@ -0,0 +1,18 @@ +import bench + +class Foo: + + def __init__(self): + self.num1 = 0 + self.num2 = 0 + self.num3 = 0 + self.num4 = 0 + self.num = 20000000 + +def test(num): + o = Foo() + i = 0 + while i < o.num: + i += 1 + +bench.run(test) diff --git a/tests/bench/var-8.1-namedtuple-5th.py b/tests/bench/var-8.1-namedtuple-5th.py new file mode 100644 index 0000000000..2cd6d15a0d --- /dev/null +++ b/tests/bench/var-8.1-namedtuple-5th.py @@ -0,0 +1,12 @@ +import bench +from _collections import namedtuple + +T = namedtuple("Tup", "foo1 foo2 foo3 foo4 num") + +def test(num): + t = T(0, 0, 0, 0, 20000000) + i = 0 + while i < t.num: + i += 1 + +bench.run(test) |