healpix_perftest.py 2.59 KB
 Martin Reinecke committed Jan 25, 2020 1 2 3 ``````import time import math import numpy as np `````` Martin Reinecke committed Jun 03, 2020 4 ``````import ducc_0_1.healpix as ph `````` Martin Reinecke committed Jan 25, 2020 5 `````` `````` Martin Reinecke committed Jun 08, 2020 6 7 ``````rng = np.random.default_rng(42) `````` Martin Reinecke committed Jan 25, 2020 8 9 10 11 12 ``````def report (name,vlen,ntry,nside,isnest,perf): print (name,": ",perf*1e-6,"MOps/s",sep="") def random_ptg(vlen): res=np.empty((vlen,2),dtype=np.float64) `````` Martin Reinecke committed Jun 08, 2020 13 14 `````` res[:,0]=np.arccos((rng.random(vlen)-0.5)*2) res[:,1]=rng.random(vlen)*2*math.pi `````` Martin Reinecke committed Jan 25, 2020 15 16 17 `````` return res def random_pix(nside,vlen): `````` Martin Reinecke committed Jun 08, 2020 18 `````` return rng.integers(low=0,high=12*nside*nside-1,size=vlen,dtype=np.int64) `````` Martin Reinecke committed Jan 25, 2020 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 `````` def dummy(vlen): inp=np.zeros(vlen,dtype=np.int64) def genperf(func,fname,inp,vlen,ntry,nside,isnest): cnt=0 t=time.time() while (cnt