diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-05 02:17:13 +0300 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2014-05-05 02:17:13 +0300 |
commit | f01fa458d869d6f89f65ba3ad163730b1e2451d6 (patch) | |
tree | c8a4b9f04e498bdd6547a752dd101c99f1c00dee /tests/bench/var-6-instance-attr.py | |
parent | aaff82afe5a72ec69e05f1e56047d0acfde91d0e (diff) | |
download | micropython-f01fa458d869d6f89f65ba3ad163730b1e2451d6.tar.gz micropython-f01fa458d869d6f89f65ba3ad163730b1e2451d6.zip |
tests/bench/var: Add tests for class/instance var access.
Also compared with method abstraction for accessing instance vars -
it's more than 3 times slower than accessing var directly.
Diffstat (limited to 'tests/bench/var-6-instance-attr.py')
-rw-r--r-- | tests/bench/var-6-instance-attr.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/bench/var-6-instance-attr.py b/tests/bench/var-6-instance-attr.py new file mode 100644 index 0000000000..787ed870fb --- /dev/null +++ b/tests/bench/var-6-instance-attr.py @@ -0,0 +1,14 @@ +import bench + +class Foo: + + def __init__(self): + self.num = 20000000 + +def test(num): + o = Foo() + i = 0 + while i < o.num: + i += 1 + +bench.run(test) |