forked from OSGeo/gdal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcomputeminmax.py
45 lines (38 loc) · 1.01 KB
/
computeminmax.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
# SPDX-License-Identifier: MIT
# Copyright 2021 Even Rouault
import timeit
from osgeo import gdal
tab_ds = {}
for dt in (
gdal.GDT_Byte,
gdal.GDT_UInt16,
gdal.GDT_Int16,
gdal.GDT_Float32,
gdal.GDT_Float64,
):
tab_ds[dt] = gdal.GetDriverByName("MEM").Create("", 10000, 1000, 1, dt)
tab_ds[dt].GetRasterBand(1).Fill(1)
def test(dt):
tab_ds[dt].GetRasterBand(1).ComputeRasterMinMax(False)
NITERS = 500
setup = "from osgeo import gdal; from __main__ import test"
print(
"testByte(): %.3f"
% timeit.timeit("test(gdal.GDT_Byte)", setup=setup, number=NITERS)
)
print(
"testUInt16(): %.3f"
% timeit.timeit("test(gdal.GDT_UInt16)", setup=setup, number=NITERS)
)
print(
"testInt16(): %.3f"
% timeit.timeit("test(gdal.GDT_Int16)", setup=setup, number=NITERS)
)
print(
"testFloat32(): %.3f"
% timeit.timeit("test(gdal.GDT_Float32)", setup=setup, number=NITERS)
)
print(
"testFloat64(): %.3f"
% timeit.timeit("test(gdal.GDT_Float64)", setup=setup, number=NITERS)
)