From 6bee5281ff6822cb97055c1fc031a4acae7dab2e Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Thu, 16 Aug 2018 22:18:08 -0400 Subject: [PATCH] Add BenchmarkCircles for simple benchmarking --- context_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/context_test.go b/context_test.go index d895f18..8f8d049 100644 --- a/context_test.go +++ b/context_test.go @@ -292,3 +292,21 @@ func TestDashes(t *testing.T) { saveImage(dc, "TestDashes") checkHash(t, dc, "d188069c69dcc3970edfac80f552b53c") } + +func BenchmarkCircles(b *testing.B) { + dc := NewContext(1000, 1000) + dc.SetRGB(1, 1, 1) + dc.Clear() + rnd := rand.New(rand.NewSource(99)) + for i := 0; i < b.N; i++ { + x := rnd.Float64() * 1000 + y := rnd.Float64() * 1000 + dc.DrawCircle(x, y, 10) + if i%2 == 0 { + dc.SetRGB(0, 0, 0) + } else { + dc.SetRGB(1, 1, 1) + } + dc.Fill() + } +}