Esempio n. 1
0
 def test3(self):
     ar = np.random.random(2048 * 2048).astype(np.float32).reshape(
         2048, 2048)
     nloop = 10
     ctime = 0
     nt = 0
     mini, maxi, mean, var = cImageD11.array_stats(ar.ravel())
     for i in range(nloop):
         start = timer()
         mini, maxi, mean, var = cImageD11.array_stats(ar.ravel())
         endc = timer()
         dt = endc - start
         ctime += dt
         nt += 1
         if ctime > 0.1:
             break
     ctime /= nt
     check = ar.min(), ar.max(), ar.mean(), ar.var()
     start = timer()
     check = ar.min(), ar.max(), ar.mean(), ar.var()
     endn = timer()
     numpytime = endn - start
     ok = np.allclose((mini, maxi, mean, var), check)
     if not ok:
         for (a, b) in zip((mini, maxi, mean, var), check):
             print(np.allclose(a, b), a, b)
     self.assertTrue(ok)
     MB_s = ar.nbytes / ctime / 1000000
     FPS = ar.nbytes / ctime / (2048 * 2048 * 4)  # Frelon float32 frame
     print(
         "array_stats: %.1f MB/s %.1f FPS(4M,f32) %.3f ms vs %.3f ms, speedup %.1f"
         % (MB_s, FPS, 1e3 * ctime, 1e3 * numpytime, numpytime / ctime))
Esempio n. 2
0
 def test1(self):
     ar = np.arange(6 * 4, dtype=np.float32).reshape(6, 4)
     mini, maxi, mean, var = cImageD11.array_stats(ar.ravel())
     t = np.allclose((mini, maxi, mean, var),
                     (ar.min(), ar.max(), ar.mean(), ar.var()))
     if not t:
         print((mini, maxi, mean, var))
         print((ar.min(), ar.max(), ar.mean(), ar.var()))
     self.assertTrue(t)
Esempio n. 3
0
 def test3( self ):
     ar = np.arange( 2048*2048, dtype=np.float32 ).reshape( 2048, 2048 )
     start = timer() 
     mini, maxi, mean, var = cImageD11.array_stats( ar.ravel() )
     endc = timer()
     check = ar.min(), ar.max(), ar.mean(), ar.var()
     endn = timer()
     self.assertTrue( np.allclose( (mini, maxi, mean, var), check ) )
     numpytime = endn - endc
     ctime = endc - start
     print("array_stats: %.3f ms vs %.3f ms, speedup %.1f"%(
         1e3*ctime, 1e3*numpytime, numpytime/ctime))
Esempio n. 4
0
 def test2(self):
     ar = np.ones(6 * 4, dtype=np.float32).reshape(6, 4)
     mini, maxi, mean, var = cImageD11.array_stats(ar.ravel())
     self.assertTrue(
         np.allclose((mini, maxi, mean, var),
                     (ar.min(), ar.max(), ar.mean(), ar.var())))