perf tests

This commit is contained in:
NatureFreshMilk 2019-01-22 13:35:15 +01:00
parent bf841f6ba0
commit 064c5f11ff
4 changed files with 30 additions and 8 deletions

View File

@ -16,6 +16,7 @@ func GetTileCoordsFromMapBlock(mbc MapBlockCoords, layers []layer.Layer) *TileCo
for _, l := range layers {
if (mbc.Y*16) >= l.From && (mbc.Y*16) <= l.To {
layerid = &l.Id
break
}
}

View File

@ -18,6 +18,15 @@ func NewTileCoords(x, y, zoom int, layerId int) *TileCoords {
return &TileCoords{X: x, Y: y, Zoom: zoom, LayerId: layerId}
}
func (tc *TileCoords) ZoomOut(n int) *TileCoords {
var nc *TileCoords = tc
for i := 1; i<n; i++ {
nc = nc.GetZoomedOutTile()
}
return nc
}
func (tc *TileCoords) GetZoomedOutTile() *TileCoords {
return &TileCoords{
X: int(math.Floor(float64(tc.X) / 2.0)),

View File

@ -4,10 +4,15 @@ import (
"mapserver/app"
"mapserver/coords"
"time"
"strconv"
"github.com/sirupsen/logrus"
)
func getTileKey(tc *coords.TileCoords) string {
return strconv.Itoa(tc.X) + "/" + strconv.Itoa(tc.Y) + "/" + strconv.Itoa(tc.Zoom)
}
func Job(ctx *app.App) {
fields := logrus.Fields{}
@ -59,17 +64,23 @@ func Job(ctx *app.App) {
}
}
//Render zoom 11-1
for _, mb := range mblist {
//13
tc := coords.GetTileCoordsFromMapBlock(mb.Pos, ctx.Config.Layers)
tileRenderedMap := make(map[string]bool)
//12
tc = tc.GetZoomedOutTile()
for i := 11; i<=1; i-- {
for _, mb := range mblist {
//13
tc := coords.GetTileCoordsFromMapBlock(mb.Pos, ctx.Config.Layers)
for tc.Zoom > 1 {
//11-1
tc = tc.GetZoomedOutTile()
tc = tc.ZoomOut(13 - i)
key := getTileKey(tc)
if tileRenderedMap[key] {
continue
}
tileRenderedMap[key] = true
fields = logrus.Fields{
"X": tc.X,

View File

@ -235,6 +235,7 @@ func (tr *TileRenderer) RenderImage(tc *coords.TileCoords, recursionDepth int) (
"Y": tc.Y,
"Zoom": tc.Zoom,
"LayerId": tc.LayerId,
"size": len(tile.Data),
"quadrender": quadrender,
"quadresize": quadresize,
"encode": encode,