diff options
-rw-r--r-- | benchmarks/benchmarks/bench_indexing.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/benchmarks/benchmarks/bench_indexing.py b/benchmarks/benchmarks/bench_indexing.py index 3e5a2ee60..a62a2050e 100644 --- a/benchmarks/benchmarks/bench_indexing.py +++ b/benchmarks/benchmarks/bench_indexing.py @@ -2,10 +2,13 @@ from __future__ import absolute_import, division, print_function from .common import Benchmark, get_squares_, get_indexes_, get_indexes_rand_ +from os.path import join as pjoin +import shutil import sys import six from numpy import memmap, float32, array import numpy as np +from tempfile import mkdtemp class Indexing(Benchmark): @@ -37,9 +40,15 @@ class Indexing(Benchmark): class IndexingSeparate(Benchmark): def setup(self): - self.fp = memmap('tmp.dat', dtype=float32, mode='w+', shape=(50, 60)) + self.tmp_dir = mkdtemp() + self.fp = memmap(pjoin(self.tmp_dir, 'tmp.dat'), + dtype=float32, mode='w+', shape=(50, 60)) self.indexes = array([3, 4, 6, 10, 20]) + def teardown(self): + del self.fp + shutil.rmtree(self.tmp_dir) + def time_mmap_slicing(self): for i in range(1000): self.fp[5:10] |