diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-07-22 23:06:00 +0200 |
|---|---|---|
| committer | Even Rouault <even.rouault@spatialys.com> | 2021-07-22 23:42:05 +0200 |
| commit | a871ada2a942624e95abc7622f9bc0d3af1f1305 (patch) | |
| tree | e04aab06f643cf1ecfb0bce64831f0e95936c8a1 /src/grids.hpp | |
| parent | 04f333c3c0ddaa9c0e21dc9bf5cccfe5614d68f4 (diff) | |
| download | PROJ-a871ada2a942624e95abc7622f9bc0d3af1f1305.tar.gz PROJ-a871ada2a942624e95abc7622f9bc0d3af1f1305.zip | |
GeoTIFF grid reading: perf improvements (fixes #2785)
With this commit, and the 2 previous ones, given mytest.cpp
```
int main()
{
PJ* pj = proj_create(nullptr, "+proj=vgridshift +grids=us_nga_egm96_15.tif");
for( int i = 0; i < 5*1000*1000; i++)
{
PJ_COORD coord;
coord.lpz.lam = 0;
coord.lpz.phi = 0;
coord.lpz.z = 0;
proj_trans(pj, PJ_FWD, coord);
}
return 0;
}
```
we get a x2 speedup
Before:
```
$ PROJ_LIB=data:$HOME/proj/PROJ-data/us_nga LD_LIBRARY_PATH=src/.libs hyperfine --warmup 1 'taskset -c 11 ./mytest'
Benchmark #1: taskset -c 11 ./mytest
Time (mean ± σ): 1.950 s ± 0.014 s [User: 1.945 s, System: 0.005 s]
Range (min … max): 1.937 s … 1.971 s
```
After:
```
$ PROJ_LIB=data:$HOME/proj/PROJ-data/us_nga LD_LIBRARY_PATH=src/.libs hyperfine --warmup 1 'taskset -c 11 ./mytest'
Benchmark #1: taskset -c 11 ./mytest
Time (mean ± σ): 984.4 ms ± 3.1 ms [User: 977.0 ms, System: 7.2 ms]
Range (min … max): 979.3 ms … 990.5 ms
```
Diffstat (limited to 'src/grids.hpp')
| -rw-r--r-- | src/grids.hpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/grids.hpp b/src/grids.hpp index d060fc95..459bde07 100644 --- a/src/grids.hpp +++ b/src/grids.hpp @@ -45,6 +45,10 @@ struct ExtentAndRes { double north; // in radian for geographic, in CRS units otherwise double resX; // in radian for geographic, in CRS units otherwise double resY; // in radian for geographic, in CRS units otherwise + double invResX; // = 1 / resX; + double invResY; // = 1 / resY; + + void computeInvRes(); bool fullWorldLongitude() const; bool contains(const ExtentAndRes &other) const; |
