diff options
| author | Damien George | 2019-06-18 23:44:16 +1000 |
|---|---|---|
| committer | Damien George | 2019-06-28 16:28:59 +1000 |
| commit | d86fb670e6d78ca38dbaedfdde35180e3b8f4bb3 (patch) | |
| tree | cfb199a27fadfd5d04d3aa13f7b22b02db555453 /tests/bench | |
| parent | d165a401dce66ba952b016d116b60e77b11f3e1f (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/bench')
44 files changed, 0 insertions, 435 deletions
diff --git a/tests/bench/arrayop-1-list_inplace.py b/tests/bench/arrayop-1-list_inplace.py deleted file mode 100644 index 0ee1ef2ec..000000000 --- a/tests/bench/arrayop-1-list_inplace.py +++ /dev/null @@ -1,12 +0,0 @@ -# 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/bench/arrayop-2-list_map.py b/tests/bench/arrayop-2-list_map.py deleted file mode 100644 index 9d5095c53..000000000 --- a/tests/bench/arrayop-2-list_map.py +++ /dev/null @@ -1,12 +0,0 @@ -# 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/bench/arrayop-3-bytearray_inplace.py b/tests/bench/arrayop-3-bytearray_inplace.py deleted file mode 100644 index a6d628070..000000000 --- a/tests/bench/arrayop-3-bytearray_inplace.py +++ /dev/null @@ -1,12 +0,0 @@ -# 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/bench/arrayop-4-bytearray_map.py b/tests/bench/arrayop-4-bytearray_map.py deleted file mode 100644 index 1b92a4096..000000000 --- a/tests/bench/arrayop-4-bytearray_map.py +++ /dev/null @@ -1,12 +0,0 @@ -# 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/bench/bench.py b/tests/bench/bench.py deleted file mode 100644 index 0cd40a93f..000000000 --- a/tests/bench/bench.py +++ /dev/null @@ -1,10 +0,0 @@ -import time - - -ITERS = 20000000 - -def run(f): - t = time.time() - f(ITERS) - t = time.time() - t - print(t) diff --git a/tests/bench/bytealloc-1-bytes_n.py b/tests/bench/bytealloc-1-bytes_n.py deleted file mode 100644 index 4a4bbc6fa..000000000 --- a/tests/bench/bytealloc-1-bytes_n.py +++ /dev/null @@ -1,7 +0,0 @@ -import bench - -def test(num): - for i in iter(range(num // 1000)): - bytes(10000) - -bench.run(test) diff --git a/tests/bench/bytealloc-2-repeat.py b/tests/bench/bytealloc-2-repeat.py deleted file mode 100644 index 786a80462..000000000 --- a/tests/bench/bytealloc-2-repeat.py +++ /dev/null @@ -1,7 +0,0 @@ -import bench - -def test(num): - for i in iter(range(num // 1000)): - b"\0" * 10000 - -bench.run(test) diff --git a/tests/bench/bytebuf-1-inplace.py b/tests/bench/bytebuf-1-inplace.py deleted file mode 100644 index 7e7d9391c..000000000 --- a/tests/bench/bytebuf-1-inplace.py +++ /dev/null @@ -1,11 +0,0 @@ -# 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/bench/bytebuf-2-join_map_bytes.py b/tests/bench/bytebuf-2-join_map_bytes.py deleted file mode 100644 index daa622991..000000000 --- a/tests/bench/bytebuf-2-join_map_bytes.py +++ /dev/null @@ -1,12 +0,0 @@ -# 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/bench/bytebuf-3-bytarray_map.py b/tests/bench/bytebuf-3-bytarray_map.py deleted file mode 100644 index 078d08e99..000000000 --- a/tests/bench/bytebuf-3-bytarray_map.py +++ /dev/null @@ -1,10 +0,0 @@ -# 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/bench/from_iter-1-list_bound.py b/tests/bench/from_iter-1-list_bound.py deleted file mode 100644 index d209daecc..000000000 --- a/tests/bench/from_iter-1-list_bound.py +++ /dev/null @@ -1,8 +0,0 @@ -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/bench/from_iter-2-list_unbound.py b/tests/bench/from_iter-2-list_unbound.py deleted file mode 100644 index be019c52f..000000000 --- a/tests/bench/from_iter-2-list_unbound.py +++ /dev/null @@ -1,8 +0,0 @@ -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/bench/from_iter-3-tuple_bound.py b/tests/bench/from_iter-3-tuple_bound.py deleted file mode 100644 index 7b7fa36c6..000000000 --- a/tests/bench/from_iter-3-tuple_bound.py +++ /dev/null @@ -1,8 +0,0 @@ -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/bench/from_iter-4-tuple_unbound.py b/tests/bench/from_iter-4-tuple_unbound.py deleted file mode 100644 index 7c7f134c8..000000000 --- a/tests/bench/from_iter-4-tuple_unbound.py +++ /dev/null @@ -1,8 +0,0 @@ -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/bench/from_iter-5-bytes_bound.py b/tests/bench/from_iter-5-bytes_bound.py deleted file mode 100644 index b793a3207..000000000 --- a/tests/bench/from_iter-5-bytes_bound.py +++ /dev/null @@ -1,8 +0,0 @@ -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/bench/from_iter-6-bytes_unbound.py b/tests/bench/from_iter-6-bytes_unbound.py deleted file mode 100644 index 20aa55627..000000000 --- a/tests/bench/from_iter-6-bytes_unbound.py +++ /dev/null @@ -1,8 +0,0 @@ -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/bench/from_iter-7-bytearray_bound.py b/tests/bench/from_iter-7-bytearray_bound.py deleted file mode 100644 index 72001a05c..000000000 --- a/tests/bench/from_iter-7-bytearray_bound.py +++ /dev/null @@ -1,8 +0,0 @@ -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/bench/from_iter-8-bytearray_unbound.py b/tests/bench/from_iter-8-bytearray_unbound.py deleted file mode 100644 index e2263b8ef..000000000 --- a/tests/bench/from_iter-8-bytearray_unbound.py +++ /dev/null @@ -1,8 +0,0 @@ -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/bench/func_args-1.1-pos_1.py b/tests/bench/func_args-1.1-pos_1.py deleted file mode 100644 index eee0ea828..000000000 --- a/tests/bench/func_args-1.1-pos_1.py +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 7e03ee2f8..000000000 --- a/tests/bench/func_args-1.2-pos_3.py +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 1fa0fbda5..000000000 --- a/tests/bench/func_args-2-pos_default_2_of_3.py +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 7bc81e5be..000000000 --- a/tests/bench/func_args-3.1-kw_1.py +++ /dev/null @@ -1,10 +0,0 @@ -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 deleted file mode 100644 index 7f9510684..000000000 --- a/tests/bench/func_args-3.2-kw_3.py +++ /dev/null @@ -1,10 +0,0 @@ -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/bench/func_builtin-1-enum_pos.py b/tests/bench/func_builtin-1-enum_pos.py deleted file mode 100644 index 20935164e..000000000 --- a/tests/bench/func_builtin-1-enum_pos.py +++ /dev/null @@ -1,7 +0,0 @@ -import bench - -def test(num): - for i in iter(range(num//20)): - enumerate([1, 2], 1) - -bench.run(test) diff --git a/tests/bench/func_builtin-2-enum_kw.py b/tests/bench/func_builtin-2-enum_kw.py deleted file mode 100644 index 6c5e44419..000000000 --- a/tests/bench/func_builtin-2-enum_kw.py +++ /dev/null @@ -1,7 +0,0 @@ -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/bench/funcall-1-inline.py b/tests/bench/funcall-1-inline.py deleted file mode 100644 index fbeb79630..000000000 --- a/tests/bench/funcall-1-inline.py +++ /dev/null @@ -1,9 +0,0 @@ -# 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/bench/funcall-2-funcall.py b/tests/bench/funcall-2-funcall.py deleted file mode 100644 index d5c36c60a..000000000 --- a/tests/bench/funcall-2-funcall.py +++ /dev/null @@ -1,12 +0,0 @@ -# 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/bench/funcall-3-funcall-local.py b/tests/bench/funcall-3-funcall-local.py deleted file mode 100644 index 1a6d728c6..000000000 --- a/tests/bench/funcall-3-funcall-local.py +++ /dev/null @@ -1,16 +0,0 @@ -# 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/bench/loop_count-1-range.py b/tests/bench/loop_count-1-range.py deleted file mode 100644 index e22adf6cb..000000000 --- a/tests/bench/loop_count-1-range.py +++ /dev/null @@ -1,7 +0,0 @@ -import bench - -def test(num): - for i in range(num): - pass - -bench.run(test) diff --git a/tests/bench/loop_count-2-range_iter.py b/tests/bench/loop_count-2-range_iter.py deleted file mode 100644 index fe4a3857e..000000000 --- a/tests/bench/loop_count-2-range_iter.py +++ /dev/null @@ -1,7 +0,0 @@ -import bench - -def test(num): - for i in iter(range(num)): - pass - -bench.run(test) diff --git a/tests/bench/loop_count-3-while_up.py b/tests/bench/loop_count-3-while_up.py deleted file mode 100644 index 1ab8054a0..000000000 --- a/tests/bench/loop_count-3-while_up.py +++ /dev/null @@ -1,8 +0,0 @@ -import bench - -def test(num): - i = 0 - while i < num: - i += 1 - -bench.run(test) diff --git a/tests/bench/loop_count-4-while_down_gt.py b/tests/bench/loop_count-4-while_down_gt.py deleted file mode 100644 index de8dee2ca..000000000 --- a/tests/bench/loop_count-4-while_down_gt.py +++ /dev/null @@ -1,7 +0,0 @@ -import bench - -def test(num): - while num > 0: - num -= 1 - -bench.run(test) diff --git a/tests/bench/loop_count-5-while_down_ne.py b/tests/bench/loop_count-5-while_down_ne.py deleted file mode 100644 index b9a1af414..000000000 --- a/tests/bench/loop_count-5-while_down_ne.py +++ /dev/null @@ -1,7 +0,0 @@ -import bench - -def test(num): - while num != 0: - num -= 1 - -bench.run(test) diff --git a/tests/bench/loop_count-5.1-while_down_ne_localvar.py b/tests/bench/loop_count-5.1-while_down_ne_localvar.py deleted file mode 100644 index 96bdb9129..000000000 --- a/tests/bench/loop_count-5.1-while_down_ne_localvar.py +++ /dev/null @@ -1,8 +0,0 @@ -import bench - -def test(num): - zero = 0 - while num != zero: - num -= 1 - -bench.run(test) diff --git a/tests/bench/var-1-constant.py b/tests/bench/var-1-constant.py deleted file mode 100644 index eec977909..000000000 --- a/tests/bench/var-1-constant.py +++ /dev/null @@ -1,8 +0,0 @@ -import bench - -def test(num): - i = 0 - while i < 20000000: - i += 1 - -bench.run(test) diff --git a/tests/bench/var-2-global.py b/tests/bench/var-2-global.py deleted file mode 100644 index 5758ad61a..000000000 --- a/tests/bench/var-2-global.py +++ /dev/null @@ -1,10 +0,0 @@ -import bench - -ITERS = 20000000 - -def test(num): - i = 0 - while i < ITERS: - i += 1 - -bench.run(test) diff --git a/tests/bench/var-3-local.py b/tests/bench/var-3-local.py deleted file mode 100644 index 124b48429..000000000 --- a/tests/bench/var-3-local.py +++ /dev/null @@ -1,10 +0,0 @@ -import bench - - -def test(num): - ITERS = 20000000 - i = 0 - while i < ITERS: - i += 1 - -bench.run(test) diff --git a/tests/bench/var-4-arg.py b/tests/bench/var-4-arg.py deleted file mode 100644 index cf050c58f..000000000 --- a/tests/bench/var-4-arg.py +++ /dev/null @@ -1,9 +0,0 @@ -import bench - - -def test(num): - i = 0 - while i < num: - i += 1 - -bench.run(lambda n:test(20000000)) diff --git a/tests/bench/var-5-class-attr.py b/tests/bench/var-5-class-attr.py deleted file mode 100644 index 02ae874ac..000000000 --- a/tests/bench/var-5-class-attr.py +++ /dev/null @@ -1,11 +0,0 @@ -import bench - -class Foo: - num = 20000000 - -def test(num): - i = 0 - while i < Foo.num: - i += 1 - -bench.run(test) diff --git a/tests/bench/var-6-instance-attr.py b/tests/bench/var-6-instance-attr.py deleted file mode 100644 index 787ed870f..000000000 --- a/tests/bench/var-6-instance-attr.py +++ /dev/null @@ -1,14 +0,0 @@ -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/bench/var-6.1-instance-attr-5.py b/tests/bench/var-6.1-instance-attr-5.py deleted file mode 100644 index e8d338360..000000000 --- a/tests/bench/var-6.1-instance-attr-5.py +++ /dev/null @@ -1,18 +0,0 @@ -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-7-instance-meth.py b/tests/bench/var-7-instance-meth.py deleted file mode 100644 index f9d463f40..000000000 --- a/tests/bench/var-7-instance-meth.py +++ /dev/null @@ -1,17 +0,0 @@ -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/bench/var-8-namedtuple-1st.py b/tests/bench/var-8-namedtuple-1st.py deleted file mode 100644 index d862480a5..000000000 --- a/tests/bench/var-8-namedtuple-1st.py +++ /dev/null @@ -1,12 +0,0 @@ -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/bench/var-8.1-namedtuple-5th.py b/tests/bench/var-8.1-namedtuple-5th.py deleted file mode 100644 index 0bcf66180..000000000 --- a/tests/bench/var-8.1-namedtuple-5th.py +++ /dev/null @@ -1,12 +0,0 @@ -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) |
