From 9925c6a812bbcccb189a29309f5f80f96ecabab6 Mon Sep 17 00:00:00 2001 From: NatureFreshMilk Date: Wed, 31 Jul 2019 12:55:08 +0200 Subject: [PATCH] proper benchmark --- mapblockrenderer/renderer_benchmark_test.go | 44 +++------------------ 1 file changed, 5 insertions(+), 39 deletions(-) diff --git a/mapblockrenderer/renderer_benchmark_test.go b/mapblockrenderer/renderer_benchmark_test.go index edd183d..18cd396 100644 --- a/mapblockrenderer/renderer_benchmark_test.go +++ b/mapblockrenderer/renderer_benchmark_test.go @@ -1,12 +1,10 @@ package mapblockrenderer import ( - "fmt" "io/ioutil" "mapserver/colormapping" "mapserver/coords" "mapserver/db/sqlite" - "mapserver/layer" "mapserver/mapblockaccessor" "mapserver/testutils" "os" @@ -19,15 +17,6 @@ import ( func BenchmarkRender(b *testing.B) { logrus.SetLevel(logrus.ErrorLevel) - layers := []*layer.Layer{ - &layer.Layer{ - Id: 0, - Name: "Base", - From: -16, - To: 160, - }, - } - tmpfile, err := ioutil.TempFile("", "TestMigrate.*.sqlite") if err != nil { panic(err) @@ -58,37 +47,14 @@ func BenchmarkRender(b *testing.B) { b.ResetTimer() for n := 0; n < b.N; n++ { - results := make(chan JobResult, 100) - jobs := make(chan JobData, 100) + pos1 := coords.NewMapBlockCoords(0, 10, 0) + pos2 := coords.NewMapBlockCoords(0, -1, 0) - go Worker(r, jobs, results) + _, err := r.Render(pos1, pos2) - go func() { - for result := range results { - if result.Data.Len() == 0 { - continue - } - - tc := coords.GetTileCoordsFromMapBlock(result.Job.Pos1, layers) - f, _ := os.Create(fmt.Sprintf("../test-output/image_%d_%d.png", tc.X, tc.Y)) - result.Data.WriteTo(f) - f.Close() - } - }() - - from := 0 - to := 0 - - for x := from; x < to; x++ { - for z := from; z < to; z++ { - pos1 := coords.NewMapBlockCoords(x, 10, z) - pos2 := coords.NewMapBlockCoords(x, -1, z) - - jobs <- JobData{Pos1: pos1, Pos2: pos2} - } + if err != nil { + panic(err) } - - close(jobs) } }