summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--benchmarks/benchmarks/bench_scalar.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/benchmarks/benchmarks/bench_scalar.py b/benchmarks/benchmarks/bench_scalar.py
index 2ad3ae670..650daa89d 100644
--- a/benchmarks/benchmarks/bench_scalar.py
+++ b/benchmarks/benchmarks/bench_scalar.py
@@ -11,6 +11,7 @@ class ScalarMath(Benchmark):
def setup(self, typename):
self.num = np.dtype(typename).type(2)
self.int32 = np.int32(2)
+ self.int32arr = np.array(2, dtype=np.int32)
def time_addition(self, typename):
n = self.num
@@ -43,3 +44,24 @@ class ScalarMath(Benchmark):
int32 + other
int32 + other
int32 + other
+
+ def time_add_int32arr_and_other(self, typename):
+ # `arr + scalar` hits the normal ufunc (array) paths.
+ int32 = self.int32arr
+ other = self.num
+ int32 + other
+ int32 + other
+ int32 + other
+ int32 + other
+ int32 + other
+
+ def time_add_other_and_int32arr(self, typename):
+ # `scalar + arr` at some point hit scalar paths in some cases, and
+ # these paths could be optimized more easily
+ int32 = self.int32arr
+ other = self.num
+ other + int32
+ other + int32
+ other + int32
+ other + int32
+ other + int32