aboutsummaryrefslogtreecommitdiff
path: root/tests/internal_bench
diff options
context:
space:
mode:
authorDamien George2019-06-18 23:44:16 +1000
committerDamien George2019-06-28 16:28:59 +1000
commitd86fb670e6d78ca38dbaedfdde35180e3b8f4bb3 (patch)
treecfb199a27fadfd5d04d3aa13f7b22b02db555453 /tests/internal_bench
parentd165a401dce66ba952b016d116b60e77b11f3e1f (diff)
tests: Rename "bench" tests to "internal_bench" and run-internalbench.py
To emphasise these benchmark tests compare the internal performance of features amongst themselves, rather than absolute performance testing.
Diffstat (limited to 'tests/internal_bench')
-rw-r--r--tests/internal_bench/arrayop-1-list_inplace.py12
-rw-r--r--tests/internal_bench/arrayop-2-list_map.py12
-rw-r--r--tests/internal_bench/arrayop-3-bytearray_inplace.py12
-rw-r--r--tests/internal_bench/arrayop-4-bytearray_map.py12
-rw-r--r--tests/internal_bench/bench.py10
-rw-r--r--tests/internal_bench/bytealloc-1-bytes_n.py7
-rw-r--r--tests/internal_bench/bytealloc-2-repeat.py7
-rw-r--r--tests/internal_bench/bytebuf-1-inplace.py11
-rw-r--r--tests/internal_bench/bytebuf-2-join_map_bytes.py12
-rw-r--r--tests/internal_bench/bytebuf-3-bytarray_map.py10
-rw-r--r--tests/internal_bench/from_iter-1-list_bound.py8
-rw-r--r--tests/internal_bench/from_iter-2-list_unbound.py8
-rw-r--r--tests/internal_bench/from_iter-3-tuple_bound.py8
-rw-r--r--tests/internal_bench/from_iter-4-tuple_unbound.py8
-rw-r--r--tests/internal_bench/from_iter-5-bytes_bound.py8
-rw-r--r--tests/internal_bench/from_iter-6-bytes_unbound.py8
-rw-r--r--tests/internal_bench/from_iter-7-bytearray_bound.py8
-rw-r--r--tests/internal_bench/from_iter-8-bytearray_unbound.py8
-rw-r--r--tests/internal_bench/func_args-1.1-pos_1.py10
-rw-r--r--tests/internal_bench/func_args-1.2-pos_3.py10
-rw-r--r--tests/internal_bench/func_args-2-pos_default_2_of_3.py10
-rw-r--r--tests/internal_bench/func_args-3.1-kw_1.py10
-rw-r--r--tests/internal_bench/func_args-3.2-kw_3.py10
-rw-r--r--tests/internal_bench/func_builtin-1-enum_pos.py7
-rw-r--r--tests/internal_bench/func_builtin-2-enum_kw.py7
-rw-r--r--tests/internal_bench/funcall-1-inline.py9
-rw-r--r--tests/internal_bench/funcall-2-funcall.py12
-rw-r--r--tests/internal_bench/funcall-3-funcall-local.py16
-rw-r--r--tests/internal_bench/loop_count-1-range.py7
-rw-r--r--tests/internal_bench/loop_count-2-range_iter.py7
-rw-r--r--tests/internal_bench/loop_count-3-while_up.py8
-rw-r--r--tests/internal_bench/loop_count-4-while_down_gt.py7
-rw-r--r--tests/internal_bench/loop_count-5-while_down_ne.py7
-rw-r--r--tests/internal_bench/loop_count-5.1-while_down_ne_localvar.py8
-rw-r--r--tests/internal_bench/var-1-constant.py8
-rw-r--r--tests/internal_bench/var-2-global.py10
-rw-r--r--tests/internal_bench/var-3-local.py10
-rw-r--r--tests/internal_bench/var-4-arg.py9
-rw-r--r--tests/internal_bench/var-5-class-attr.py11
-rw-r--r--tests/internal_bench/var-6-instance-attr.py14
-rw-r--r--tests/internal_bench/var-6.1-instance-attr-5.py18
-rw-r--r--tests/internal_bench/var-7-instance-meth.py17
-rw-r--r--tests/internal_bench/var-8-namedtuple-1st.py12
-rw-r--r--tests/internal_bench/var-8.1-namedtuple-5th.py12
44 files changed, 435 insertions, 0 deletions
diff --git a/tests/internal_bench/arrayop-1-list_inplace.py b/tests/internal_bench/arrayop-1-list_inplace.py
new file mode 100644
index 000000000..0ee1ef2ec
--- /dev/null
+++ b/tests/internal_bench/arrayop-1-list_inplace.py
@@ -0,0 +1,12 @@
+# Array operation
+# Type: list, inplace operation using for. What's good about this
+# method is that it doesn't require any extra memory allocation.
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ arr = [0] * 1000
+ for i in range(len(arr)):
+ arr[i] += 1
+
+bench.run(test)
diff --git a/tests/internal_bench/arrayop-2-list_map.py b/tests/internal_bench/arrayop-2-list_map.py
new file mode 100644
index 000000000..9d5095c53
--- /dev/null
+++ b/tests/internal_bench/arrayop-2-list_map.py
@@ -0,0 +1,12 @@
+# Array operation
+# Type: list, map() call. This method requires allocation of
+# the same amount of memory as original array (to hold result
+# array). On the other hand, input array stays intact.
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ arr = [0] * 1000
+ arr2 = list(map(lambda x: x + 1, arr))
+
+bench.run(test)
diff --git a/tests/internal_bench/arrayop-3-bytearray_inplace.py b/tests/internal_bench/arrayop-3-bytearray_inplace.py
new file mode 100644
index 000000000..a6d628070
--- /dev/null
+++ b/tests/internal_bench/arrayop-3-bytearray_inplace.py
@@ -0,0 +1,12 @@
+# Array operation
+# Type: bytearray, inplace operation using for. What's good about this
+# method is that it doesn't require any extra memory allocation.
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ arr = bytearray(b"\0" * 1000)
+ for i in range(len(arr)):
+ arr[i] += 1
+
+bench.run(test)
diff --git a/tests/internal_bench/arrayop-4-bytearray_map.py b/tests/internal_bench/arrayop-4-bytearray_map.py
new file mode 100644
index 000000000..1b92a4096
--- /dev/null
+++ b/tests/internal_bench/arrayop-4-bytearray_map.py
@@ -0,0 +1,12 @@
+# Array operation
+# Type: list, map() call. This method requires allocation of
+# the same amount of memory as original array (to hold result
+# array). On the other hand, input array stays intact.
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ arr = bytearray(b"\0" * 1000)
+ arr2 = bytearray(map(lambda x: x + 1, arr))
+
+bench.run(test)
diff --git a/tests/internal_bench/bench.py b/tests/internal_bench/bench.py
new file mode 100644
index 000000000..0cd40a93f
--- /dev/null
+++ b/tests/internal_bench/bench.py
@@ -0,0 +1,10 @@
+import time
+
+
+ITERS = 20000000
+
+def run(f):
+ t = time.time()
+ f(ITERS)
+ t = time.time() - t
+ print(t)
diff --git a/tests/internal_bench/bytealloc-1-bytes_n.py b/tests/internal_bench/bytealloc-1-bytes_n.py
new file mode 100644
index 000000000..4a4bbc6fa
--- /dev/null
+++ b/tests/internal_bench/bytealloc-1-bytes_n.py
@@ -0,0 +1,7 @@
+import bench
+
+def test(num):
+ for i in iter(range(num // 1000)):
+ bytes(10000)
+
+bench.run(test)
diff --git a/tests/internal_bench/bytealloc-2-repeat.py b/tests/internal_bench/bytealloc-2-repeat.py
new file mode 100644
index 000000000..786a80462
--- /dev/null
+++ b/tests/internal_bench/bytealloc-2-repeat.py
@@ -0,0 +1,7 @@
+import bench
+
+def test(num):
+ for i in iter(range(num // 1000)):
+ b"\0" * 10000
+
+bench.run(test)
diff --git a/tests/internal_bench/bytebuf-1-inplace.py b/tests/internal_bench/bytebuf-1-inplace.py
new file mode 100644
index 000000000..7e7d9391c
--- /dev/null
+++ b/tests/internal_bench/bytebuf-1-inplace.py
@@ -0,0 +1,11 @@
+# Doing some operation on bytearray
+# Inplace - the most memory efficient way
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ ba = bytearray(b"\0" * 1000)
+ for i in range(len(ba)):
+ ba[i] += 1
+
+bench.run(test)
diff --git a/tests/internal_bench/bytebuf-2-join_map_bytes.py b/tests/internal_bench/bytebuf-2-join_map_bytes.py
new file mode 100644
index 000000000..daa622991
--- /dev/null
+++ b/tests/internal_bench/bytebuf-2-join_map_bytes.py
@@ -0,0 +1,12 @@
+# Doing some operation on bytearray
+# Pretty weird way - map bytearray thru function, but make sure that
+# function return bytes of size 1, then join them together. Surely,
+# this is slowest way to do it.
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ ba = bytearray(b"\0" * 1000)
+ ba2 = b''.join(map(lambda x:bytes([x + 1]), ba))
+
+bench.run(test)
diff --git a/tests/internal_bench/bytebuf-3-bytarray_map.py b/tests/internal_bench/bytebuf-3-bytarray_map.py
new file mode 100644
index 000000000..078d08e99
--- /dev/null
+++ b/tests/internal_bench/bytebuf-3-bytarray_map.py
@@ -0,0 +1,10 @@
+# Doing some operation on bytearray
+# No joins, but still map().
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ ba = bytearray(b"\0" * 1000)
+ ba2 = bytearray(map(lambda x: x + 1, ba))
+
+bench.run(test)
diff --git a/tests/internal_bench/from_iter-1-list_bound.py b/tests/internal_bench/from_iter-1-list_bound.py
new file mode 100644
index 000000000..d209daecc
--- /dev/null
+++ b/tests/internal_bench/from_iter-1-list_bound.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ l = [0] * 1000
+ l2 = list(l)
+
+bench.run(test)
diff --git a/tests/internal_bench/from_iter-2-list_unbound.py b/tests/internal_bench/from_iter-2-list_unbound.py
new file mode 100644
index 000000000..be019c52f
--- /dev/null
+++ b/tests/internal_bench/from_iter-2-list_unbound.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ l = [0] * 1000
+ l2 = list(map(lambda x: x, l))
+
+bench.run(test)
diff --git a/tests/internal_bench/from_iter-3-tuple_bound.py b/tests/internal_bench/from_iter-3-tuple_bound.py
new file mode 100644
index 000000000..7b7fa36c6
--- /dev/null
+++ b/tests/internal_bench/from_iter-3-tuple_bound.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ l = [0] * 1000
+ l2 = tuple(l)
+
+bench.run(test)
diff --git a/tests/internal_bench/from_iter-4-tuple_unbound.py b/tests/internal_bench/from_iter-4-tuple_unbound.py
new file mode 100644
index 000000000..7c7f134c8
--- /dev/null
+++ b/tests/internal_bench/from_iter-4-tuple_unbound.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ l = [0] * 1000
+ l2 = tuple(map(lambda x: x, l))
+
+bench.run(test)
diff --git a/tests/internal_bench/from_iter-5-bytes_bound.py b/tests/internal_bench/from_iter-5-bytes_bound.py
new file mode 100644
index 000000000..b793a3207
--- /dev/null
+++ b/tests/internal_bench/from_iter-5-bytes_bound.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ l = [0] * 1000
+ l2 = bytes(l)
+
+bench.run(test)
diff --git a/tests/internal_bench/from_iter-6-bytes_unbound.py b/tests/internal_bench/from_iter-6-bytes_unbound.py
new file mode 100644
index 000000000..20aa55627
--- /dev/null
+++ b/tests/internal_bench/from_iter-6-bytes_unbound.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ l = [0] * 1000
+ l2 = bytes(map(lambda x: x, l))
+
+bench.run(test)
diff --git a/tests/internal_bench/from_iter-7-bytearray_bound.py b/tests/internal_bench/from_iter-7-bytearray_bound.py
new file mode 100644
index 000000000..72001a05c
--- /dev/null
+++ b/tests/internal_bench/from_iter-7-bytearray_bound.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ l = [0] * 1000
+ l2 = bytearray(l)
+
+bench.run(test)
diff --git a/tests/internal_bench/from_iter-8-bytearray_unbound.py b/tests/internal_bench/from_iter-8-bytearray_unbound.py
new file mode 100644
index 000000000..e2263b8ef
--- /dev/null
+++ b/tests/internal_bench/from_iter-8-bytearray_unbound.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ for i in iter(range(num//10000)):
+ l = [0] * 1000
+ l2 = bytearray(map(lambda x: x, l))
+
+bench.run(test)
diff --git a/tests/internal_bench/func_args-1.1-pos_1.py b/tests/internal_bench/func_args-1.1-pos_1.py
new file mode 100644
index 000000000..eee0ea828
--- /dev/null
+++ b/tests/internal_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/internal_bench/func_args-1.2-pos_3.py b/tests/internal_bench/func_args-1.2-pos_3.py
new file mode 100644
index 000000000..7e03ee2f8
--- /dev/null
+++ b/tests/internal_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/internal_bench/func_args-2-pos_default_2_of_3.py b/tests/internal_bench/func_args-2-pos_default_2_of_3.py
new file mode 100644
index 000000000..1fa0fbda5
--- /dev/null
+++ b/tests/internal_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/internal_bench/func_args-3.1-kw_1.py b/tests/internal_bench/func_args-3.1-kw_1.py
new file mode 100644
index 000000000..7bc81e5be
--- /dev/null
+++ b/tests/internal_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/internal_bench/func_args-3.2-kw_3.py b/tests/internal_bench/func_args-3.2-kw_3.py
new file mode 100644
index 000000000..7f9510684
--- /dev/null
+++ b/tests/internal_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)
diff --git a/tests/internal_bench/func_builtin-1-enum_pos.py b/tests/internal_bench/func_builtin-1-enum_pos.py
new file mode 100644
index 000000000..20935164e
--- /dev/null
+++ b/tests/internal_bench/func_builtin-1-enum_pos.py
@@ -0,0 +1,7 @@
+import bench
+
+def test(num):
+ for i in iter(range(num//20)):
+ enumerate([1, 2], 1)
+
+bench.run(test)
diff --git a/tests/internal_bench/func_builtin-2-enum_kw.py b/tests/internal_bench/func_builtin-2-enum_kw.py
new file mode 100644
index 000000000..6c5e44419
--- /dev/null
+++ b/tests/internal_bench/func_builtin-2-enum_kw.py
@@ -0,0 +1,7 @@
+import bench
+
+def test(num):
+ for i in iter(range(num//20)):
+ enumerate(iterable=[1, 2], start=1)
+
+bench.run(test)
diff --git a/tests/internal_bench/funcall-1-inline.py b/tests/internal_bench/funcall-1-inline.py
new file mode 100644
index 000000000..fbeb79630
--- /dev/null
+++ b/tests/internal_bench/funcall-1-inline.py
@@ -0,0 +1,9 @@
+# Function call overhead test
+# Establish a baseline for performing a trivial operation inline
+import bench
+
+def test(num):
+ for i in iter(range(num)):
+ a = i + 1
+
+bench.run(test)
diff --git a/tests/internal_bench/funcall-2-funcall.py b/tests/internal_bench/funcall-2-funcall.py
new file mode 100644
index 000000000..d5c36c60a
--- /dev/null
+++ b/tests/internal_bench/funcall-2-funcall.py
@@ -0,0 +1,12 @@
+# Function call overhead test
+# Perform the same trivial operation as global function call
+import bench
+
+def f(x):
+ return x + 1
+
+def test(num):
+ for i in iter(range(num)):
+ a = f(i)
+
+bench.run(test)
diff --git a/tests/internal_bench/funcall-3-funcall-local.py b/tests/internal_bench/funcall-3-funcall-local.py
new file mode 100644
index 000000000..1a6d728c6
--- /dev/null
+++ b/tests/internal_bench/funcall-3-funcall-local.py
@@ -0,0 +1,16 @@
+# Function call overhead test
+# Perform the same trivial operation as calling function, cached in a
+# local variable. This is commonly known optimization for overly dynamic
+# languages (the idea is to cut on symbolic look up overhead, as local
+# variables are accessed by offset, not by name)
+import bench
+
+def f(x):
+ return x + 1
+
+def test(num):
+ f_ = f
+ for i in iter(range(num)):
+ a = f_(i)
+
+bench.run(test)
diff --git a/tests/internal_bench/loop_count-1-range.py b/tests/internal_bench/loop_count-1-range.py
new file mode 100644
index 000000000..e22adf6cb
--- /dev/null
+++ b/tests/internal_bench/loop_count-1-range.py
@@ -0,0 +1,7 @@
+import bench
+
+def test(num):
+ for i in range(num):
+ pass
+
+bench.run(test)
diff --git a/tests/internal_bench/loop_count-2-range_iter.py b/tests/internal_bench/loop_count-2-range_iter.py
new file mode 100644
index 000000000..fe4a3857e
--- /dev/null
+++ b/tests/internal_bench/loop_count-2-range_iter.py
@@ -0,0 +1,7 @@
+import bench
+
+def test(num):
+ for i in iter(range(num)):
+ pass
+
+bench.run(test)
diff --git a/tests/internal_bench/loop_count-3-while_up.py b/tests/internal_bench/loop_count-3-while_up.py
new file mode 100644
index 000000000..1ab8054a0
--- /dev/null
+++ b/tests/internal_bench/loop_count-3-while_up.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ i = 0
+ while i < num:
+ i += 1
+
+bench.run(test)
diff --git a/tests/internal_bench/loop_count-4-while_down_gt.py b/tests/internal_bench/loop_count-4-while_down_gt.py
new file mode 100644
index 000000000..de8dee2ca
--- /dev/null
+++ b/tests/internal_bench/loop_count-4-while_down_gt.py
@@ -0,0 +1,7 @@
+import bench
+
+def test(num):
+ while num > 0:
+ num -= 1
+
+bench.run(test)
diff --git a/tests/internal_bench/loop_count-5-while_down_ne.py b/tests/internal_bench/loop_count-5-while_down_ne.py
new file mode 100644
index 000000000..b9a1af414
--- /dev/null
+++ b/tests/internal_bench/loop_count-5-while_down_ne.py
@@ -0,0 +1,7 @@
+import bench
+
+def test(num):
+ while num != 0:
+ num -= 1
+
+bench.run(test)
diff --git a/tests/internal_bench/loop_count-5.1-while_down_ne_localvar.py b/tests/internal_bench/loop_count-5.1-while_down_ne_localvar.py
new file mode 100644
index 000000000..96bdb9129
--- /dev/null
+++ b/tests/internal_bench/loop_count-5.1-while_down_ne_localvar.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ zero = 0
+ while num != zero:
+ num -= 1
+
+bench.run(test)
diff --git a/tests/internal_bench/var-1-constant.py b/tests/internal_bench/var-1-constant.py
new file mode 100644
index 000000000..eec977909
--- /dev/null
+++ b/tests/internal_bench/var-1-constant.py
@@ -0,0 +1,8 @@
+import bench
+
+def test(num):
+ i = 0
+ while i < 20000000:
+ i += 1
+
+bench.run(test)
diff --git a/tests/internal_bench/var-2-global.py b/tests/internal_bench/var-2-global.py
new file mode 100644
index 000000000..5758ad61a
--- /dev/null
+++ b/tests/internal_bench/var-2-global.py
@@ -0,0 +1,10 @@
+import bench
+
+ITERS = 20000000
+
+def test(num):
+ i = 0
+ while i < ITERS:
+ i += 1
+
+bench.run(test)
diff --git a/tests/internal_bench/var-3-local.py b/tests/internal_bench/var-3-local.py
new file mode 100644
index 000000000..124b48429
--- /dev/null
+++ b/tests/internal_bench/var-3-local.py
@@ -0,0 +1,10 @@
+import bench
+
+
+def test(num):
+ ITERS = 20000000
+ i = 0
+ while i < ITERS:
+ i += 1
+
+bench.run(test)
diff --git a/tests/internal_bench/var-4-arg.py b/tests/internal_bench/var-4-arg.py
new file mode 100644
index 000000000..cf050c58f
--- /dev/null
+++ b/tests/internal_bench/var-4-arg.py
@@ -0,0 +1,9 @@
+import bench
+
+
+def test(num):
+ i = 0
+ while i < num:
+ i += 1
+
+bench.run(lambda n:test(20000000))
diff --git a/tests/internal_bench/var-5-class-attr.py b/tests/internal_bench/var-5-class-attr.py
new file mode 100644
index 000000000..02ae874ac
--- /dev/null
+++ b/tests/internal_bench/var-5-class-attr.py
@@ -0,0 +1,11 @@
+import bench
+
+class Foo:
+ num = 20000000
+
+def test(num):
+ i = 0
+ while i < Foo.num:
+ i += 1
+
+bench.run(test)
diff --git a/tests/internal_bench/var-6-instance-attr.py b/tests/internal_bench/var-6-instance-attr.py
new file mode 100644
index 000000000..787ed870f
--- /dev/null
+++ b/tests/internal_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)
diff --git a/tests/internal_bench/var-6.1-instance-attr-5.py b/tests/internal_bench/var-6.1-instance-attr-5.py
new file mode 100644
index 000000000..e8d338360
--- /dev/null
+++ b/tests/internal_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/internal_bench/var-7-instance-meth.py b/tests/internal_bench/var-7-instance-meth.py
new file mode 100644
index 000000000..f9d463f40
--- /dev/null
+++ b/tests/internal_bench/var-7-instance-meth.py
@@ -0,0 +1,17 @@
+import bench
+
+class Foo:
+
+ def __init__(self):
+ self._num = 20000000
+
+ def num(self):
+ return self._num
+
+def test(num):
+ o = Foo()
+ i = 0
+ while i < o.num():
+ i += 1
+
+bench.run(test)
diff --git a/tests/internal_bench/var-8-namedtuple-1st.py b/tests/internal_bench/var-8-namedtuple-1st.py
new file mode 100644
index 000000000..d862480a5
--- /dev/null
+++ b/tests/internal_bench/var-8-namedtuple-1st.py
@@ -0,0 +1,12 @@
+import bench
+from ucollections import namedtuple
+
+T = namedtuple("Tup", ["num", "bar"])
+
+def test(num):
+ t = T(20000000, 0)
+ i = 0
+ while i < t.num:
+ i += 1
+
+bench.run(test)
diff --git a/tests/internal_bench/var-8.1-namedtuple-5th.py b/tests/internal_bench/var-8.1-namedtuple-5th.py
new file mode 100644
index 000000000..0bcf66180
--- /dev/null
+++ b/tests/internal_bench/var-8.1-namedtuple-5th.py
@@ -0,0 +1,12 @@
+import bench
+from ucollections 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)