Skip to content

Commit 16ab9b6

Browse files
committed
BENCH: Expand array-creation tests
This adds some simple additional tests, one for a list of NumPy scalars. Another for generally lists, both integers and floats as one common cases (floats previously had some super-fast paths). As well as a test with the dtype given, since that may make some differences.
1 parent ea7f5eb commit 16ab9b6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

benchmarks/benchmarks/bench_core.py

+16
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@ class Core(Benchmark):
77
def setup(self):
88
self.l100 = range(100)
99
self.l50 = range(50)
10+
self.float_l1000 = [float(i) for i in range(1000)]
11+
self.float64_l1000 = [np.float64(i) for i in range(1000)]
12+
self.int_l1000 = list(range(1000))
1013
self.l = [np.arange(1000), np.arange(1000)]
1114
self.l_view = [memoryview(a) for a in self.l]
1215
self.l10x10 = np.ones((10, 10))
16+
self.float64_dtype = np.dtype(np.float64)
1317

1418
def time_array_1(self):
1519
np.array(1)
@@ -23,6 +27,18 @@ def time_array_l1(self):
2327
def time_array_l100(self):
2428
np.array(self.l100)
2529

30+
def time_array_float_l1000(self):
31+
np.array(self.float_l1000)
32+
33+
def time_array_float_l1000_dtype(self):
34+
np.array(self.float_l1000, dtype=self.float64_dtype)
35+
36+
def time_array_float64_l1000(self):
37+
np.array(self.float64_l1000)
38+
39+
def time_array_int_l1000(self):
40+
np.array(self.int_l1000)
41+
2642
def time_array_l(self):
2743
np.array(self.l)
2844

0 commit comments

Comments
 (0)