From bc44e254b00895844f1952c73eeea3cfd765984c Mon Sep 17 00:00:00 2001 From: Martin Czygan Date: Sun, 4 Jul 2021 21:34:56 +0200 Subject: update docs --- skate/zipkey/batch_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'skate/zipkey/batch_test.go') diff --git a/skate/zipkey/batch_test.go b/skate/zipkey/batch_test.go index 38a1307..6156fbf 100644 --- a/skate/zipkey/batch_test.go +++ b/skate/zipkey/batch_test.go @@ -40,11 +40,15 @@ func TestBatcherLarge(t *testing.T) { N = 1000000 numWorkers = 24 size = 7000 + // We share a single writer across threads, so we need to guard each // write. TODO: measure performance impact. mu sync.Mutex buf bytes.Buffer - f = func(g *Group) error { + + // The reducer is a simple function that will write "1" into the + // buffer, if the groups are equal, "0" otherwise. + f = func(g *Group) error { var v string if reflect.DeepEqual(g.G0, g.G1) { v = "1" @@ -62,6 +66,7 @@ func TestBatcherLarge(t *testing.T) { ) b.Size = size b.NumWorkers = numWorkers + for i := 0; i < N; i++ { var u, v string if i%2 == 0 { @@ -87,3 +92,5 @@ func TestBatcherLarge(t *testing.T) { t.Fatalf("got %v, want %v (count0=%v, buf=%s)", count1, N/2, count0, buf.String()) } } + +// TODO: BenchmarkBatcher with different worker counts. -- cgit v1.2.3