def test_mask(self, benchmark, prefix, drop, shared_dist_ctx, io_backend): io_backend = backends_by_name[io_backend] hdr = os.path.join(prefix, K2IS_FILE) flist = filelist(hdr) ctx = shared_dist_ctx ds = ctx.load(filetype="k2is", path=hdr, io_backend=io_backend) def mask(): return np.ones(ds.shape.sig, dtype=bool) udf = ApplyMasksUDF(mask_factories=[mask], backends=('numpy', )) # warmup executor ctx.run_udf(udf=udf, dataset=ds) if drop == "cold_cache": drop_cache(flist) elif drop == "warm_cache": warmup_cache(flist) else: raise ValueError("bad param") benchmark.pedantic( ctx.run_udf, kwargs=dict(udf=udf, dataset=ds), warmup_rounds=0, rounds=1, iterations=1, )
def test_mask(self, benchmark, drop, shared_dist_ctx, lt_ctx, context, chunked_emd): if context == 'dist': ctx = shared_dist_ctx elif context == 'inline': ctx = lt_ctx else: raise ValueError ds = chunked_emd def mask(): return np.ones(ds.shape.sig, dtype=bool) udf = ApplyMasksUDF(mask_factories=[mask], backends=('numpy', )) # warmup executor ctx.run_udf(udf=udf, dataset=ds) if drop == "cold_cache": drop_cache([ds.path]) elif drop == "warm_cache": warmup_cache([ds.path]) else: raise ValueError("bad param") benchmark.pedantic(ctx.run_udf, kwargs=dict(udf=udf, dataset=ds), warmup_rounds=0, rounds=1, iterations=1)
def test_sparse_roi(self, benchmark, prefix, drop, io_backend, shared_dist_ctx, sparsity): io_backend = backends_by_name[io_backend] mib_hdr = os.path.join(prefix, MIB_FILE) flist = filelist(mib_hdr) ctx = shared_dist_ctx ds = ctx.load(filetype="mib", path=mib_hdr, io_backend=io_backend) sparse_roi = np.zeros(ds.shape.nav.size, dtype=bool) sparse_roi[::sparsity] = True def mask(): return np.ones(ds.shape.sig, dtype=bool) udf = ApplyMasksUDF(mask_factories=[mask], backends=('numpy', )) # warmup executor ctx.run_udf(udf=udf, dataset=ds) if drop == "cold_cache": drop_cache(flist) elif drop == "warm_cache": warmup_cache(flist) else: raise ValueError("bad param") benchmark.pedantic( ctx.run_udf, kwargs=dict(udf=udf, dataset=ds, roi=sparse_roi), warmup_rounds=0, rounds=1, iterations=1, )
def test_sequential(benchmark, prefix, drop): hdr = os.path.join(prefix, K2IS_FILE) flist = filelist(hdr) if drop == "cold_cache": drop_cache(flist) elif drop == "warm_cache": warmup_cache(flist) else: raise ValueError("bad param") benchmark.pedantic(warmup_cache, args=(flist, ), warmup_rounds=0, rounds=1, iterations=1)