|
14 | 14 | * limitations under the License. |
15 | 15 | */ |
16 | 16 |
|
17 | | -// package geotrellis.server |
| 17 | +package geotrellis.server |
18 | 18 |
|
19 | | -// import geotrellis.server.vlm.geotiff._ |
20 | | -// import geotrellis.server.vlm.gdal._ |
| 19 | +import geotrellis.server.vlm.geotiff._ |
| 20 | +import geotrellis.raster.MultibandTile |
| 21 | +import com.azavea.maml.ast._ |
| 22 | +import com.azavea.maml.error._ |
| 23 | +import com.azavea.maml.eval.ConcurrentInterpreter |
| 24 | +import cats.effect._ |
| 25 | +import io.chrisdavenport.log4cats.slf4j.Slf4jLogger |
21 | 26 |
|
22 | | -// import geotrellis.raster.MultibandTile |
23 | | -// import com.azavea.maml.ast._ |
24 | | -// import com.azavea.maml.error._ |
25 | | -// import com.azavea.maml.util.Square |
26 | | -// import com.azavea.maml.eval.BufferingInterpreter |
27 | | -// import cats.effect._ |
28 | | -// import org.openjdk.jmh.annotations._ |
29 | | -// import org.gdal.gdal.gdalJNI |
| 27 | +import org.openjdk.jmh.annotations._ |
30 | 28 |
|
31 | | -// import scala.concurrent.ExecutionContext |
32 | | -// import java.net.URI |
| 29 | +import scala.concurrent.ExecutionContext |
| 30 | +import java.net.URI |
33 | 31 |
|
| 32 | +@BenchmarkMode(Array(Mode.AverageTime)) |
| 33 | +@State(Scope.Thread) |
| 34 | +class TmsReificationBench { |
34 | 35 |
|
35 | | -// @BenchmarkMode(Array(Mode.AverageTime)) |
36 | | -// @State(Scope.Thread) |
37 | | -// class TmsReificationBench { |
| 36 | + implicit val logger = Slf4jLogger.getLogger[IO] |
| 37 | + implicit var contextShift = IO.contextShift(ExecutionContext.global) |
38 | 38 |
|
39 | | -// // gdal performance will be obscured by the caching it attempts |
40 | | -// gdalJNI.SetConfigOption("GDAL_CACHEMAX", "0") |
| 39 | + // NDVI |
| 40 | + val ast: Expression = |
| 41 | + Division(List(Subtraction(List(RasterVar("red"), RasterVar("nir"))), Addition(List(RasterVar("red"), RasterVar("nir"))))) |
41 | 42 |
|
42 | | -// implicit var contextShift = IO.contextShift(ExecutionContext.global) |
| 43 | + // red, green, NIR bands which should have data for z/x/y 9/454/200 |
| 44 | + val geotiffVars = Map( |
| 45 | + "red" -> GeoTiffNode(new URI("https://s3.amazonaws.com/geotrellis-test/daunnc/r-g-nir-with-ovrs.tif"), 0, None), |
| 46 | + "nir" -> GeoTiffNode(new URI("https://s3.amazonaws.com/geotrellis-test/daunnc/r-g-nir-with-ovrs.tif"), 2, None) |
| 47 | + ) |
43 | 48 |
|
44 | | -// // NDVI |
45 | | -// val ast = |
46 | | -// Division(List( |
47 | | -// Subtraction(List( |
48 | | -// RasterVar("red"), |
49 | | -// RasterVar("nir"))), |
50 | | -// Addition(List( |
51 | | -// RasterVar("red"), |
52 | | -// RasterVar("nir")) |
53 | | -// )) |
54 | | -// ) |
| 49 | + val gdalVars = Map( |
| 50 | + "red" -> GeoTiffNode(new URI("gdal+https://s3.amazonaws.com/geotrellis-test/daunnc/r-g-nir-with-ovrs.tif"), 0, None), |
| 51 | + "nir" -> GeoTiffNode(new URI("gdal+https://s3.amazonaws.com/geotrellis-test/daunnc/r-g-nir-with-ovrs.tif"), 2, None) |
| 52 | + ) |
55 | 53 |
|
56 | | -// // red, green, NIR bands which should have data for z/x/y 9/454/200 |
57 | | -// val geotiffVars = Map( |
58 | | -// "red" -> GeoTiffNode(new URI("https://s3.amazonaws.com/geotrellis-test/daunnc/r-g-nir-with-ovrs.tif"), 0, None), |
59 | | -// "nir" -> GeoTiffNode(new URI("https://s3.amazonaws.com/geotrellis-test/daunnc/r-g-nir-with-ovrs.tif"), 2, None) |
60 | | -// ) |
61 | | -// val gdalVars = Map( |
62 | | -// "red" -> GDALNode(new URI("https://s3.amazonaws.com/geotrellis-test/daunnc/r-g-nir-with-ovrs.tif"), 0, None), |
63 | | -// "nir" -> GDALNode(new URI("https://s3.amazonaws.com/geotrellis-test/daunnc/r-g-nir-with-ovrs.tif"), 2, None) |
64 | | -// ) |
| 54 | + @Setup(Level.Trial) |
| 55 | + def setup(): Unit = {} |
65 | 56 |
|
66 | | -// @Setup(Level.Trial) |
67 | | -// def setup(): Unit = {} |
| 57 | + @Benchmark |
| 58 | + def geotiffLayerTms: Interpreted[MultibandTile] = { |
| 59 | + val eval = LayerTms(IO(ast), IO(geotiffVars), ConcurrentInterpreter.DEFAULT[IO]) |
| 60 | + eval(9, 454, 200).unsafeRunSync |
| 61 | + } |
68 | 62 |
|
69 | | -// @Benchmark |
70 | | -// def geotiffLayerTms: Interpreted[MultibandTile] = { |
71 | | -// val eval = LayerTms(IO(ast), IO(geotiffVars), BufferingInterpreter.DEFAULT) |
72 | | -// eval(9, 454, 200).unsafeRunSync |
73 | | -// } |
74 | | - |
75 | | -// @Benchmark |
76 | | -// def gdalLayerTms: Interpreted[MultibandTile] = { |
77 | | -// val eval = LayerTms(IO(ast), IO(gdalVars), BufferingInterpreter.DEFAULT) |
78 | | -// eval(9, 454, 200).unsafeRunSync |
79 | | -// } |
80 | | -// } |
| 63 | + @Benchmark |
| 64 | + def gdalLayerTms: Interpreted[MultibandTile] = { |
| 65 | + val eval = LayerTms(IO(ast), IO(gdalVars), ConcurrentInterpreter.DEFAULT[IO]) |
| 66 | + eval(9, 454, 200).unsafeRunSync |
| 67 | + } |
| 68 | +} |
0 commit comments