1313
1414import blosc2
1515
16- dtype = np .float64
16+ dtype = np .int64
1717shape = (10_000 , 10_000 )
18+ cparams = blosc2 .CParams (codec = blosc2 .Codec .BLOSCLZ , clevel = 1 )
1819
1920@blosc2 .dsl_kernel
2021def kernel_ramp ():
@@ -23,25 +24,30 @@ def kernel_ramp():
2324
2425print (kernel_ramp .dsl_source )
2526a = blosc2 .lazyudf (kernel_ramp , (), dtype = dtype , shape = shape )
26- npa = a .compute (cparams = dict ( clevel = 1 , codec = blosc2 . Codec . LZ4 ) )
27+ npa = a .compute (cparams = cparams )
2728t0 = time ()
2829result = npa .sum ()
2930# print(result)
3031print ("Blosc2 sum over NDArray:" , round (time () - t0 , 3 ), "s" )
3132
3233t0 = time ()
3334a = blosc2 .lazyudf (kernel_ramp , (), dtype = dtype , shape = shape )
34- result = a .sum ()
35+ result = a .sum (cparams = cparams )
3536# print(result)
3637print ("Blosc2 sum over LazyArray:" , round (time () - t0 , 3 ), "s" )
3738
3839t0 = time ()
3940a = blosc2 .lazyudf (kernel_ramp , (), dtype = dtype , shape = shape )
40- # result = a.compute(cparams=dict(clevel=1, codec=blosc2.Codec.LZ4)).sum()
41- result = a .compute ().sum ()
41+ result = a .compute (cparams = cparams ).sum ()
4242# print(result)
4343print ("(with a prior .compute):" , round (time () - t0 , 3 ), "s" )
4444
45+ t0 = time ()
46+ a = blosc2 .arange (np .prod (shape ), dtype = dtype , shape = shape , cparams = cparams )
47+ result = a .sum ()
48+ # print(result)
49+ print ("Blosc2 arange + sum:" , round (time () - t0 , 3 ), "s" )
50+
4551t0 = time ()
4652npa = np .arange (np .prod (shape ), dtype = dtype ).reshape (shape )
4753result = npa .sum ()
0 commit comments