Skip to content

Commit

Permalink
PERF: add 0d structured indexing benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
pv authored and ahaldane committed Oct 18, 2015
1 parent 37382ac commit 8cf5b50
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions benchmarks/benchmarks/bench_indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,26 @@ def time_mmap_slicing(self):
def time_mmap_fancy_indexing(self):
for i in range(1000):
self.fp[self.indexes]


class IndexingStructured0D(Benchmark):
def setup(self):
self.dt = np.dtype([('a', 'f4', 256)])

self.A = np.zeros((), self.dt)
self.B = self.A.copy()

self.a = np.zeros(1, self.dt)[0]
self.b = self.a.copy()

def time_array_slice(self):
self.B['a'][:] = self.A['a']

def time_array_all(self):
self.B['a'] = self.A['a']

def time_scalar_slice(self):
self.b['a'][:] = self.a['a']

def time_scalar_all(self):
self.b['a'] = self.a['a']

0 comments on commit 8cf5b50

Please sign in to comment.