Skip to content

Commit 7e912a3

Browse files
committed
Add benchmarks
1 parent 2b906dc commit 7e912a3

File tree

1 file changed

+37
-1
lines changed
  • lib/node_modules/@stdlib/ndarray/benchmark/python/numpy

1 file changed

+37
-1
lines changed

lib/node_modules/@stdlib/ndarray/benchmark/python/numpy/benchmark.py

+37-1
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,48 @@ def main():
102102
"""Run the benchmarks."""
103103
print_version()
104104

105-
name = "::1d,instantiation"
105+
name = "::1d,instantiation,linear_buffer"
106106
setup = "import numpy as np; x = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0];"
107107
stmt = "y = np.array(x)"
108108
iterations = 100000
109109
benchmark(name, setup, stmt, iterations)
110110

111+
name = "::1d,instantiation,ndarray"
112+
setup = "import numpy as np; x = np.array( [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] );"
113+
stmt = "y = np.array(x)"
114+
iterations = 100000
115+
benchmark(name, setup, stmt, iterations)
116+
117+
name = "::1d,instantiation,no_cast"
118+
setup = "import numpy as np; x = np.array( [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] );"
119+
stmt = "y = np.array(x, dtype='float64')"
120+
iterations = 100000
121+
benchmark(name, setup, stmt, iterations)
122+
123+
name = "::1d,instantiation,default_cast"
124+
setup = "import numpy as np; x = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0];"
125+
stmt = "y = np.array(x, dtype='float64')"
126+
iterations = 100000
127+
benchmark(name, setup, stmt, iterations)
128+
129+
name = "::1d,instantiation,dtype_cast"
130+
setup = "import numpy as np; x = np.array( [1.0, 2.0, 3.0, 4.0, 5.0, 6.0], dtype='float32');"
131+
stmt = "y = np.array(x, dtype='float64')"
132+
iterations = 100000
133+
benchmark(name, setup, stmt, iterations)
134+
135+
name = "::1d,instantiation:copy=false"
136+
setup = "import numpy as np; x = np.array( [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] );"
137+
stmt = "y = np.array(x, copy=False)"
138+
iterations = 100000
139+
benchmark(name, setup, stmt, iterations)
140+
141+
name = "::1d,instantiation:copy=true"
142+
setup = "import numpy as np; x = np.array( [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] );"
143+
stmt = "y = np.array(x, copy=True)"
144+
iterations = 100000
145+
benchmark(name, setup, stmt, iterations)
146+
111147
print_summary(COUNT[0], COUNT[0])
112148

113149

0 commit comments

Comments
 (0)