diff --git a/bench/insert_redis_test.go b/bench/insert_redis_test.go new file mode 100644 index 0000000..d47fc18 --- /dev/null +++ b/bench/insert_redis_test.go @@ -0,0 +1,286 @@ +package bench + +import ( + "context" + "log" + "os" + "testing" + + "github.com/go-redis/redis/v8" + + clickhousebuffer "github.com/zikwall/clickhouse-buffer/v3" + "github.com/zikwall/clickhouse-buffer/v3/example/pkg/tables" + "github.com/zikwall/clickhouse-buffer/v3/src/buffer/cxredis" + "github.com/zikwall/clickhouse-buffer/v3/src/cx" +) + +// x10 +// goos: linux +// goarch: amd64 +// pkg: github.com/zikwall/clickhouse-buffer/v3/bench +// cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz +// BenchmarkInsertRedisObjects/10000-12 10 2165062600 ns/op 8949147 B/op 215127 allocs/op +// BenchmarkInsertRedisObjects/1000-12 10 205537440 ns/op 960664 B/op 23209 allocs/op +// BenchmarkInsertRedisObjects/100-12 10 20371570 ns/op 96292 B/op 2323 allocs/op +// BenchmarkInsertRedisObjects/10-12 10 2216160 ns/op 1868 B/op 32 allocs/op +// BenchmarkInsertRedisObjects/1-12 10 180490 ns/op 188 B/op 3 allocs/op +// PASS +// ok +// nolint:funlen,dupl // it's not important here +func BenchmarkInsertRedisObjects(b *testing.B) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + client := clickhousebuffer.NewClientWithOptions(ctx, &clickhouseMock{}, + clickhousebuffer.DefaultOptions(). + SetDebugMode(false). + SetFlushInterval(10000). + SetBatchSize(1000), + ) + redisHost := os.Getenv("REDIS_HOST") + redisPass := os.Getenv("REDIS_PASS") + var writeAPI clickhousebuffer.Writer + b.ResetTimer() + + b.Run("10000", func(b *testing.B) { + client.Options().SetBatchSize(10000) + rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ + Addr: redisHost, + Password: redisPass, + DB: 11, + }), "bucket", client.Options().BatchSize()) + if err != nil { + log.Panicln(err) + } + writeAPI = client.Writer( + cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), + rxbuffer, + ) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + insertObjects(writeAPI, 10000, b) + } + }) + + b.Run("1000", func(b *testing.B) { + client.Options().SetBatchSize(1000) + rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ + Addr: redisHost, + Password: redisPass, + }), "bucket", client.Options().BatchSize()) + if err != nil { + log.Panicln(err) + } + writeAPI = client.Writer( + cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), + rxbuffer, + ) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + insertObjects(writeAPI, 1000, b) + } + }) + + b.Run("100", func(b *testing.B) { + client.Options().SetBatchSize(100) + rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ + Addr: redisHost, + Password: redisPass, + }), "bucket", client.Options().BatchSize()) + if err != nil { + log.Panicln(err) + } + writeAPI = client.Writer( + cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), + rxbuffer, + ) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + insertObjects(writeAPI, 100, b) + } + }) + + b.Run("10", func(b *testing.B) { + client.Options().SetBatchSize(10) + rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ + Addr: redisHost, + Password: redisPass, + }), "bucket", client.Options().BatchSize()) + if err != nil { + log.Panicln(err) + } + writeAPI = client.Writer( + cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), + rxbuffer, + ) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + insertObjects(writeAPI, 10, b) + } + }) + + b.Run("1", func(b *testing.B) { + client.Options().SetBatchSize(1) + rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ + Addr: redisHost, + Password: redisPass, + }), "bucket", client.Options().BatchSize()) + if err != nil { + log.Panicln(err) + } + writeAPI = client.Writer( + cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), + rxbuffer, + ) + b.ResetTimer() + + for i := 0; i < b.N; i++ { + insertObjects(writeAPI, 1, b) + } + }) + + b.StopTimer() + writeAPI.Close() + client.Close() +} + +// x10 +// goos: linux +// goarch: amd64 +// pkg: github.com/zikwall/clickhouse-buffer/v3/bench +// cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz +// BenchmarkInsertRedisVectors/10000-12 10 2035777840 ns/op 9124870 B/op 223549 allocs/op +// BenchmarkInsertRedisVectors/1000-12 10 208882330 ns/op 926325 B/op 22709 allocs/op +// BenchmarkInsertRedisVectors/100-12 10 19944150 ns/op 92810 B/op 2273 allocs/op +// BenchmarkInsertRedisVectors/10-12 10 1891890 ns/op 1588 B/op 28 allocs/op +// BenchmarkInsertRedisVectors/1-12 10 182180 ns/op 160 B/op 2 allocs/op +// PASS +// ok +// nolint:funlen,dupl // it's not important here +func BenchmarkInsertRedisVectors(b *testing.B) { + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + client := clickhousebuffer.NewClientWithOptions(ctx, &clickhouseMock{}, + clickhousebuffer.DefaultOptions(). + SetDebugMode(false). + SetFlushInterval(10000). + SetBatchSize(1000), + ) + redisHost := os.Getenv("REDIS_HOST") + redisPass := os.Getenv("REDIS_PASS") + var writeAPI clickhousebuffer.Writer + b.ResetTimer() + + b.Run("10000", func(b *testing.B) { + b.StopTimer() + client.Options().SetBatchSize(10000) + rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ + Addr: redisHost, + Password: redisPass, + DB: 11, + }), "bucket", client.Options().BatchSize()) + if err != nil { + log.Panicln(err) + } + writeAPI = client.Writer( + cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), + rxbuffer, + ) + b.StartTimer() + + for i := 0; i < b.N; i++ { + insertVectors(writeAPI, 10000, b) + } + }) + + b.Run("1000", func(b *testing.B) { + b.StopTimer() + client.Options().SetBatchSize(1000) + rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ + Addr: redisHost, + Password: redisPass, + }), "bucket", client.Options().BatchSize()) + if err != nil { + log.Panicln(err) + } + writeAPI = client.Writer( + cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), + rxbuffer, + ) + b.StartTimer() + + for i := 0; i < b.N; i++ { + insertVectors(writeAPI, 1000, b) + } + }) + + b.Run("100", func(b *testing.B) { + b.StopTimer() + client.Options().SetBatchSize(100) + rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ + Addr: redisHost, + Password: redisPass, + }), "bucket", client.Options().BatchSize()) + if err != nil { + log.Panicln(err) + } + writeAPI = client.Writer( + cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), + rxbuffer, + ) + b.StartTimer() + + for i := 0; i < b.N; i++ { + insertVectors(writeAPI, 100, b) + } + }) + + b.Run("10", func(b *testing.B) { + b.StopTimer() + client.Options().SetBatchSize(10) + rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ + Addr: redisHost, + Password: redisPass, + }), "bucket", client.Options().BatchSize()) + if err != nil { + log.Panicln(err) + } + writeAPI = client.Writer( + cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), + rxbuffer, + ) + b.StartTimer() + + for i := 0; i < b.N; i++ { + insertVectors(writeAPI, 10, b) + } + }) + + b.Run("1", func(b *testing.B) { + b.StopTimer() + client.Options().SetBatchSize(1) + rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ + Addr: redisHost, + Password: redisPass, + }), "bucket", client.Options().BatchSize()) + if err != nil { + log.Panicln(err) + } + writeAPI = client.Writer( + cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), + rxbuffer, + ) + b.StartTimer() + + for i := 0; i < b.N; i++ { + insertVectors(writeAPI, 1, b) + } + }) + + b.StopTimer() + writeAPI.Close() + client.Close() +} diff --git a/bench/insert_simple_test.go b/bench/insert_simple_test.go index df571b8..d072bea 100644 --- a/bench/insert_simple_test.go +++ b/bench/insert_simple_test.go @@ -2,18 +2,13 @@ package bench import ( "context" - "log" - "os" "testing" "time" "github.com/ClickHouse/clickhouse-go/v2/lib/driver" - "github.com/go-redis/redis/v8" - clickhousebuffer "github.com/zikwall/clickhouse-buffer/v3" "github.com/zikwall/clickhouse-buffer/v3/example/pkg/tables" "github.com/zikwall/clickhouse-buffer/v3/src/buffer/cxmem" - "github.com/zikwall/clickhouse-buffer/v3/src/buffer/cxredis" "github.com/zikwall/clickhouse-buffer/v3/src/cx" ) @@ -41,131 +36,90 @@ func (c *clickhouseMock) Conn() driver.Conn { return nil } -// x10 +// x50 // goos: linux // goarch: amd64 // pkg: github.com/zikwall/clickhouse-buffer/v3/bench // cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz -// BenchmarkInsertRedisObjects/10000-12 10 2165062600 ns/op 8949147 B/op 215127 allocs/op -// BenchmarkInsertRedisObjects/1000-12 10 205537440 ns/op 960664 B/op 23209 allocs/op -// BenchmarkInsertRedisObjects/100-12 10 20371570 ns/op 96292 B/op 2323 allocs/op -// BenchmarkInsertRedisObjects/10-12 10 2216160 ns/op 1868 B/op 32 allocs/op -// BenchmarkInsertRedisObjects/1-12 10 180490 ns/op 188 B/op 3 allocs/op +// BenchmarkInsertSimplestPreallocateVectors/1000000-12 1000 142919 ns/op 0 B/op 0 allocs/op +// BenchmarkInsertSimplestPreallocateVectors/100000-12 1000 12498 ns/op 0 B/op 0 allocs/op +// BenchmarkInsertSimplestPreallocateVectors/10000-12 1000 1265 ns/op 0 B/op 0 allocs/op +// BenchmarkInsertSimplestPreallocateVectors/1000-12 1000 143.1 ns/op 0 B/op 0 allocs/op +// BenchmarkInsertSimplestPreallocateVectors/100-12 1000 5.700 ns/op 2 B/op 0 allocs/op // PASS // ok -// nolint:funlen,dupl // it's not important here -func BenchmarkInsertRedisObjects(b *testing.B) { +// nolint:lll,dupl // it's OK +func BenchmarkInsertSimplestPreallocateVectors(b *testing.B) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + client := clickhousebuffer.NewClientWithOptions(ctx, &clickhouseMock{}, clickhousebuffer.DefaultOptions(). SetDebugMode(false). - SetFlushInterval(10000). - SetBatchSize(1000), + SetFlushInterval(10000000). + SetBatchSize(10000000), ) - redisHost := os.Getenv("REDIS_HOST") - redisPass := os.Getenv("REDIS_PASS") + var writeAPI clickhousebuffer.Writer b.ResetTimer() - b.Run("10000", func(b *testing.B) { - client.Options().SetBatchSize(10000) - rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ - Addr: redisHost, - Password: redisPass, - DB: 11, - }), "bucket", client.Options().BatchSize()) - if err != nil { - log.Panicln(err) - } + b.Run("1000000", func(b *testing.B) { + client.Options().SetBatchSize(1000001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - rxbuffer, + cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 10000, b) + insertPreAllocatedVectors(writeAPI, 1000000, b) } }) - b.Run("1000", func(b *testing.B) { - client.Options().SetBatchSize(1000) - rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ - Addr: redisHost, - Password: redisPass, - }), "bucket", client.Options().BatchSize()) - if err != nil { - log.Panicln(err) - } + b.Run("100000", func(b *testing.B) { + client.Options().SetBatchSize(100001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - rxbuffer, + cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 1000, b) + insertPreAllocatedVectors(writeAPI, 100000, b) } }) - b.Run("100", func(b *testing.B) { - client.Options().SetBatchSize(100) - rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ - Addr: redisHost, - Password: redisPass, - }), "bucket", client.Options().BatchSize()) - if err != nil { - log.Panicln(err) - } + b.Run("10000", func(b *testing.B) { + client.Options().SetBatchSize(10001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - rxbuffer, + cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 100, b) + insertPreAllocatedVectors(writeAPI, 10000, b) } }) - b.Run("10", func(b *testing.B) { - client.Options().SetBatchSize(10) - rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ - Addr: redisHost, - Password: redisPass, - }), "bucket", client.Options().BatchSize()) - if err != nil { - log.Panicln(err) - } + b.Run("1000", func(b *testing.B) { + client.Options().SetBatchSize(1001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - rxbuffer, + cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 10, b) + insertPreAllocatedVectors(writeAPI, 1000, b) } }) - b.Run("1", func(b *testing.B) { - client.Options().SetBatchSize(1) - rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ - Addr: redisHost, - Password: redisPass, - }), "bucket", client.Options().BatchSize()) - if err != nil { - log.Panicln(err) - } + b.Run("100", func(b *testing.B) { + client.Options().SetBatchSize(101) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - rxbuffer, + cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 1, b) + insertPreAllocatedVectors(writeAPI, 100, b) } }) @@ -174,131 +128,90 @@ func BenchmarkInsertRedisObjects(b *testing.B) { client.Close() } -// x10 +// x1000 // goos: linux // goarch: amd64 // pkg: github.com/zikwall/clickhouse-buffer/v3/bench // cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz -// BenchmarkInsertRedisVectors/10000-12 10 2035777840 ns/op 9124870 B/op 223549 allocs/op -// BenchmarkInsertRedisVectors/1000-12 10 208882330 ns/op 926325 B/op 22709 allocs/op -// BenchmarkInsertRedisVectors/100-12 10 19944150 ns/op 92810 B/op 2273 allocs/op -// BenchmarkInsertRedisVectors/10-12 10 1891890 ns/op 1588 B/op 28 allocs/op -// BenchmarkInsertRedisVectors/1-12 10 182180 ns/op 160 B/op 2 allocs/op +// BenchmarkInsertSimplestPreallocateObjects/1000000-12 1000 399110 ns/op 88000 B/op 3000 allocs/op +// BenchmarkInsertSimplestPreallocateObjects/100000-12 1000 37527 ns/op 8800 B/op 300 allocs/op +// BenchmarkInsertSimplestPreallocateObjects/10000-12 1000 3880 ns/op 880 B/op 30 allocs/op +// BenchmarkInsertSimplestPreallocateObjects/1000-12 1000 419.5 ns/op 88 B/op 3 allocs/op +// BenchmarkInsertSimplestPreallocateObjects/100-12 1000 58.90 ns/op 11 B/op 0 allocs/op // PASS // ok -// nolint:funlen,dupl // it's not important here -func BenchmarkInsertRedisVectors(b *testing.B) { +// nolint:lll,dupl // it's OK +func BenchmarkInsertSimplestPreallocateObjects(b *testing.B) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() + client := clickhousebuffer.NewClientWithOptions(ctx, &clickhouseMock{}, clickhousebuffer.DefaultOptions(). SetDebugMode(false). - SetFlushInterval(10000). - SetBatchSize(1000), + SetFlushInterval(10000000). + SetBatchSize(10000000), ) - redisHost := os.Getenv("REDIS_HOST") - redisPass := os.Getenv("REDIS_PASS") + var writeAPI clickhousebuffer.Writer b.ResetTimer() - b.Run("10000", func(b *testing.B) { - client.Options().SetBatchSize(10000) - rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ - Addr: redisHost, - Password: redisPass, - DB: 11, - }), "bucket", client.Options().BatchSize()) - if err != nil { - log.Panicln(err) - } + b.Run("1000000", func(b *testing.B) { + client.Options().SetBatchSize(1000001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - rxbuffer, + cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 10000, b) + insertPreAllocatedObjects(writeAPI, 1000000, b) } }) - b.Run("1000", func(b *testing.B) { - client.Options().SetBatchSize(1000) - rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ - Addr: redisHost, - Password: redisPass, - }), "bucket", client.Options().BatchSize()) - if err != nil { - log.Panicln(err) - } + b.Run("100000", func(b *testing.B) { + client.Options().SetBatchSize(100001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - rxbuffer, + cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 1000, b) + insertPreAllocatedObjects(writeAPI, 100000, b) } }) - b.Run("100", func(b *testing.B) { - client.Options().SetBatchSize(100) - rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ - Addr: redisHost, - Password: redisPass, - }), "bucket", client.Options().BatchSize()) - if err != nil { - log.Panicln(err) - } + b.Run("10000", func(b *testing.B) { + client.Options().SetBatchSize(10001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - rxbuffer, + cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 100, b) + insertPreAllocatedObjects(writeAPI, 10000, b) } }) - b.Run("10", func(b *testing.B) { - client.Options().SetBatchSize(10) - rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ - Addr: redisHost, - Password: redisPass, - }), "bucket", client.Options().BatchSize()) - if err != nil { - log.Panicln(err) - } + b.Run("1000", func(b *testing.B) { + client.Options().SetBatchSize(1001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - rxbuffer, + cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 10, b) + insertPreAllocatedObjects(writeAPI, 1000, b) } }) - b.Run("1", func(b *testing.B) { - client.Options().SetBatchSize(1) - rxbuffer, err := cxredis.NewBuffer(ctx, redis.NewClient(&redis.Options{ - Addr: redisHost, - Password: redisPass, - }), "bucket", client.Options().BatchSize()) - if err != nil { - log.Panicln(err) - } + b.Run("100", func(b *testing.B) { + client.Options().SetBatchSize(101) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - rxbuffer, + cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 1, b) + insertPreAllocatedObjects(writeAPI, 100, b) } }) @@ -307,21 +220,20 @@ func BenchmarkInsertRedisVectors(b *testing.B) { client.Close() } -// x50 +// x1000 // goos: linux // goarch: amd64 // pkg: github.com/zikwall/clickhouse-buffer/v3/bench // cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz -// BenchmarkInsertSimplestPreallocateVectors/10000000-12 50 25841852 ns/op 4800020 B/op 0 allocs/op -// BenchmarkInsertSimplestPreallocateVectors/1000000-12 50 2611338 ns/op 480053 B/op 0 allocs/op -// BenchmarkInsertSimplestPreallocateVectors/100000-12 50 252132 ns/op 48005 B/op 0 allocs/op -// BenchmarkInsertSimplestPreallocateVectors/10000-12 50 33340 ns/op 4915 B/op 0 allocs/op -// BenchmarkInsertSimplestPreallocateVectors/1000-12 50 3496 ns/op 492 B/op 0 allocs/op -// BenchmarkInsertSimplestPreallocateVectors/100-12 50 102.0 ns/op 54 B/op 0 allocs/op +// BenchmarkInsertSimplestObjects/1000000-12 1000 454794 ns/op 160002 B/op 4000 allocs/op +// BenchmarkInsertSimplestObjects/100000-12 1000 41879 ns/op 16000 B/op 400 allocs/op +// BenchmarkInsertSimplestObjects/10000-12 1000 4174 ns/op 1605 B/op 40 allocs/op +// BenchmarkInsertSimplestObjects/1000-12 1000 479.5 ns/op 160 B/op 4 allocs/op +// BenchmarkInsertSimplestObjects/100-12 1000 39.40 ns/op 16 B/op 0 allocs/op // PASS // ok // nolint:lll,dupl // it's OK -func BenchmarkInsertSimplestPreallocateVectors(b *testing.B) { +func BenchmarkInsertSimplestObjects(b *testing.B) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -335,75 +247,63 @@ func BenchmarkInsertSimplestPreallocateVectors(b *testing.B) { var writeAPI clickhousebuffer.Writer b.ResetTimer() - b.Run("10000000", func(b *testing.B) { - client.Options().SetBatchSize(10000000) - writeAPI = client.Writer( - cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - cxmem.NewBuffer(client.Options().BatchSize()), - ) - b.ResetTimer() - for i := 0; i < b.N; i++ { - insertPreAllocatedVectors(writeAPI, 10000000, b) - } - }) - b.Run("1000000", func(b *testing.B) { - client.Options().SetBatchSize(1000000) + client.Options().SetBatchSize(1000001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() for i := 0; i < b.N; i++ { - insertPreAllocatedVectors(writeAPI, 1000000, b) + insertObjects(writeAPI, 1000000, b) } }) b.Run("100000", func(b *testing.B) { - client.Options().SetBatchSize(100000) + client.Options().SetBatchSize(100001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() for i := 0; i < b.N; i++ { - insertPreAllocatedVectors(writeAPI, 100000, b) + insertObjects(writeAPI, 100000, b) } }) b.Run("10000", func(b *testing.B) { - client.Options().SetBatchSize(10000) + client.Options().SetBatchSize(10001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() for i := 0; i < b.N; i++ { - insertPreAllocatedVectors(writeAPI, 10000, b) + insertObjects(writeAPI, 10000, b) } }) b.Run("1000", func(b *testing.B) { - client.Options().SetBatchSize(1000) + client.Options().SetBatchSize(1001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() for i := 0; i < b.N; i++ { - insertPreAllocatedVectors(writeAPI, 1000, b) + insertObjects(writeAPI, 1000, b) } }) b.Run("100", func(b *testing.B) { - client.Options().SetBatchSize(100) + client.Options().SetBatchSize(101) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() for i := 0; i < b.N; i++ { - insertPreAllocatedVectors(writeAPI, 100, b) + insertObjects(writeAPI, 100, b) } }) @@ -412,21 +312,20 @@ func BenchmarkInsertSimplestPreallocateVectors(b *testing.B) { client.Close() } -// x50 +// X1000 // goos: linux // goarch: amd64 // pkg: github.com/zikwall/clickhouse-buffer/v3/bench // cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz -// BenchmarkInsertSimplestPreallocateObjects/10000000-12 50 80617426 ns/op 22400022 B/op 600000 allocs/op -// BenchmarkInsertSimplestPreallocateObjects/1000000-12 50 7746850 ns/op 2240051 B/op 60000 allocs/op -// BenchmarkInsertSimplestPreallocateObjects/100000-12 50 900776 ns/op 224005 B/op 6000 allocs/op -// BenchmarkInsertSimplestPreallocateObjects/10000-12 50 75438 ns/op 22515 B/op 600 allocs/op -// BenchmarkInsertSimplestPreallocateObjects/1000-12 50 7454 ns/op 2252 B/op 60 allocs/op -// BenchmarkInsertSimplestPreallocateObjects/100-12 50 618.0 ns/op 230 B/op 6 allocs/op +// BenchmarkInsertSimplestObjectsJust/10000000-12 1000 4705290 ns/op 1360000 B/op 40000 allocs/op +// BenchmarkInsertSimplestObjectsJust/1000000-12 1000 410051 ns/op 136000 B/op 4000 allocs/op +// BenchmarkInsertSimplestObjectsJust/100000-12 1000 45773 ns/op 13600 B/op 400 allocs/op +// BenchmarkInsertSimplestObjectsJust/10000-12 1000 4851 ns/op 1360 B/op 40 allocs/op +// BenchmarkInsertSimplestObjectsJust/1000-12 1000 431.4 ns/op 136 B/op 4 allocs/op +// BenchmarkInsertSimplestObjectsJust/100-12 1000 66.40 ns/op 13 B/op 0 allocs/op // PASS // ok -// nolint:lll,dupl // it's OK -func BenchmarkInsertSimplestPreallocateObjects(b *testing.B) { +func BenchmarkInsertSimplestObjectsJust(b *testing.B) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -441,75 +340,63 @@ func BenchmarkInsertSimplestPreallocateObjects(b *testing.B) { b.ResetTimer() b.Run("10000000", func(b *testing.B) { - client.Options().SetBatchSize(10000000) + client.Options().SetBatchSize(10000001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertPreAllocatedObjects(writeAPI, 10000000, b) - } + insertObjects(writeAPI, 10000000, b) }) b.Run("1000000", func(b *testing.B) { - client.Options().SetBatchSize(1000000) + client.Options().SetBatchSize(1000001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertPreAllocatedObjects(writeAPI, 1000000, b) - } + insertObjects(writeAPI, 1000000, b) }) b.Run("100000", func(b *testing.B) { - client.Options().SetBatchSize(100000) + client.Options().SetBatchSize(100001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertPreAllocatedObjects(writeAPI, 100000, b) - } + insertObjects(writeAPI, 100000, b) }) b.Run("10000", func(b *testing.B) { - client.Options().SetBatchSize(10000) + client.Options().SetBatchSize(10001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertPreAllocatedObjects(writeAPI, 10000, b) - } + insertObjects(writeAPI, 10000, b) }) b.Run("1000", func(b *testing.B) { - client.Options().SetBatchSize(1000) + client.Options().SetBatchSize(1001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertPreAllocatedObjects(writeAPI, 1000, b) - } + insertObjects(writeAPI, 1000, b) }) b.Run("100", func(b *testing.B) { - client.Options().SetBatchSize(100) + client.Options().SetBatchSize(101) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertPreAllocatedObjects(writeAPI, 100, b) - } + insertObjects(writeAPI, 100, b) }) b.StopTimer() @@ -517,21 +404,20 @@ func BenchmarkInsertSimplestPreallocateObjects(b *testing.B) { client.Close() } -// x50 +// x1000 // goos: linux // goarch: amd64 // pkg: github.com/zikwall/clickhouse-buffer/v3/bench // cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz -// BenchmarkInsertSimplestObjects/10000000-12 50 88113322 ns/op 32000020 B/op 800000 allocs/op -// BenchmarkInsertSimplestObjects/1000000-12 50 8273780 ns/op 3200052 B/op 80000 allocs/op -// BenchmarkInsertSimplestObjects/100000-12 50 891610 ns/op 320005 B/op 8000 allocs/op -// BenchmarkInsertSimplestObjects/10000-12 50 83918 ns/op 27200 B/op 800 allocs/op -// BenchmarkInsertSimplestObjects/1000-12 50 8258 ns/op 3212 B/op 80 allocs/op -// BenchmarkInsertSimplestObjects/100-12 50 818.0 ns/op 326 B/op 8 allocs/op +// BenchmarkInsertSimplestVectors/1000000-12 1000 182548 ns/op 72002 B/op 1000 allocs/op +// BenchmarkInsertSimplestVectors/100000-12 1000 16291 ns/op 7200 B/op 100 allocs/op +// BenchmarkInsertSimplestVectors/10000-12 1000 1638 ns/op 725 B/op 10 allocs/op +// BenchmarkInsertSimplestVectors/1000-12 1000 208.4 ns/op 72 B/op 1 allocs/op +// BenchmarkInsertSimplestVectors/100-12 1000 20.00 ns/op 7 B/op 0 allocs/op // PASS // ok // nolint:lll,dupl // it's OK -func BenchmarkInsertSimplestObjects(b *testing.B) { +func BenchmarkInsertSimplestVectors(b *testing.B) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -539,81 +425,69 @@ func BenchmarkInsertSimplestObjects(b *testing.B) { clickhousebuffer.DefaultOptions(). SetDebugMode(false). SetFlushInterval(10000000). - SetBatchSize(10000000), + SetBatchSize(100), ) var writeAPI clickhousebuffer.Writer b.ResetTimer() - b.Run("10000000", func(b *testing.B) { - client.Options().SetBatchSize(10000000) - writeAPI = client.Writer( - cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - cxmem.NewBuffer(client.Options().BatchSize()), - ) - b.ResetTimer() - for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 10000000, b) - } - }) - b.Run("1000000", func(b *testing.B) { - client.Options().SetBatchSize(1000000) + client.Options().SetBatchSize(1000001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 1000000, b) + insertVectors(writeAPI, 1000000, b) } }) b.Run("100000", func(b *testing.B) { - client.Options().SetBatchSize(100000) + client.Options().SetBatchSize(100001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 100000, b) + insertVectors(writeAPI, 100000, b) } }) b.Run("10000", func(b *testing.B) { - client.Options().SetBatchSize(10000) + client.Options().SetBatchSize(10001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 10000, b) + insertVectors(writeAPI, 10000, b) } }) b.Run("1000", func(b *testing.B) { - client.Options().SetBatchSize(1000) + client.Options().SetBatchSize(1001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 1000, b) + insertVectors(writeAPI, 1000, b) } }) b.Run("100", func(b *testing.B) { - client.Options().SetBatchSize(100) + client.Options().SetBatchSize(101) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() for i := 0; i < b.N; i++ { - insertObjects(writeAPI, 100, b) + insertVectors(writeAPI, 100, b) } }) @@ -622,22 +496,20 @@ func BenchmarkInsertSimplestObjects(b *testing.B) { client.Close() } -// ~2x total more effective than WriteRow -// x50 +// X1000 // goos: linux // goarch: amd64 // pkg: github.com/zikwall/clickhouse-buffer/v3/bench // cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz -// BenchmarkInsertSimplestVectors/10000000-12 50 75695376 ns/op 14400020 B/op 200000 allocs/op -// BenchmarkInsertSimplestVectors/1000000-12 50 5001434 ns/op 1440051 B/op 20000 allocs/op -// BenchmarkInsertSimplestVectors/100000-12 50 403230 ns/op 144005 B/op 2000 allocs/op -// BenchmarkInsertSimplestVectors/10000-12 50 33936 ns/op 14515 B/op 200 allocs/op -// BenchmarkInsertSimplestVectors/1000-12 50 3140 ns/op 1452 B/op 20 allocs/op -// BenchmarkInsertSimplestVectors/100-12 50 186.0 ns/op 150 B/op 2 allocs/op +// BenchmarkInsertSimplestVectorsJust/10000000-12 1000 2059182 ns/op 480000 B/op 10000 allocs/op +// BenchmarkInsertSimplestVectorsJust/1000000-12 1000 176129 ns/op 48000 B/op 1000 allocs/op +// BenchmarkInsertSimplestVectorsJust/100000-12 1000 17398 ns/op 4800 B/op 100 allocs/op +// BenchmarkInsertSimplestVectorsJust/10000-12 1000 1937 ns/op 480 B/op 10 allocs/op +// BenchmarkInsertSimplestVectorsJust/1000-12 1000 243.9 ns/op 48 B/op 1 allocs/op +// BenchmarkInsertSimplestVectorsJust/100-12 1000 10.50 ns/op 4 B/op 0 allocs/op // PASS // ok -// nolint:lll,dupl // it's OK -func BenchmarkInsertSimplestVectors(b *testing.B) { +func BenchmarkInsertSimplestVectorsJust(b *testing.B) { ctx, cancel := context.WithCancel(context.Background()) defer cancel() @@ -645,82 +517,70 @@ func BenchmarkInsertSimplestVectors(b *testing.B) { clickhousebuffer.DefaultOptions(). SetDebugMode(false). SetFlushInterval(10000000). - SetBatchSize(100), + SetBatchSize(10000000), ) var writeAPI clickhousebuffer.Writer b.ResetTimer() b.Run("10000000", func(b *testing.B) { - client.Options().SetBatchSize(10000000) + client.Options().SetBatchSize(10000001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 10000000, b) - } + insertVectors(writeAPI, 10000000, b) }) b.Run("1000000", func(b *testing.B) { - client.Options().SetBatchSize(1000000) + client.Options().SetBatchSize(1000001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 1000000, b) - } + insertVectors(writeAPI, 1000000, b) }) b.Run("100000", func(b *testing.B) { - client.Options().SetBatchSize(100000) + client.Options().SetBatchSize(100001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 100000, b) - } + insertVectors(writeAPI, 100000, b) }) b.Run("10000", func(b *testing.B) { - client.Options().SetBatchSize(10000) + client.Options().SetBatchSize(10001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 10000, b) - } + insertVectors(writeAPI, 10000, b) }) b.Run("1000", func(b *testing.B) { - client.Options().SetBatchSize(1000) + client.Options().SetBatchSize(1001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 1000, b) - } + insertVectors(writeAPI, 1000, b) }) b.Run("100", func(b *testing.B) { - client.Options().SetBatchSize(100) + client.Options().SetBatchSize(101) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), ) b.ResetTimer() - for i := 0; i < b.N; i++ { - insertVectors(writeAPI, 100, b) - } + insertVectors(writeAPI, 100, b) }) b.StopTimer() @@ -728,16 +588,16 @@ func BenchmarkInsertSimplestVectors(b *testing.B) { client.Close() } +// X1000 // goos: linux // goarch: amd64 // pkg: github.com/zikwall/clickhouse-buffer/v3/bench // cpu: Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz -// BenchmarkInsertSimplestEmptyVectors/10000000-12 100 22317607 ns/op 0 B/op 0 allocs/op -// BenchmarkInsertSimplestEmptyVectors/1000000-12 100 1246957 ns/op 240026 B/op 0 allocs/op -// BenchmarkInsertSimplestEmptyVectors/100000-12 100 125928 ns/op 24002 B/op 0 allocs/op -// BenchmarkInsertSimplestEmptyVectors/10000-12 100 13788 ns/op 2457 B/op 0 allocs/op -// BenchmarkInsertSimplestEmptyVectors/1000-12 100 1475 ns/op 246 B/op 0 allocs/op -// BenchmarkInsertSimplestEmptyVectors/100-12 100 282.0 ns/op 54 B/op 0 allocs/op +// BenchmarkInsertSimplestEmptyVectors/1000000-12 1000 132887 ns/op 24002 B/op 0 allocs/op +// BenchmarkInsertSimplestEmptyVectors/100000-12 1000 13404 ns/op 2400 B/op 0 allocs/op +// BenchmarkInsertSimplestEmptyVectors/10000-12 1000 1299 ns/op 245 B/op 0 allocs/op +// BenchmarkInsertSimplestEmptyVectors/1000-12 1000 122.1 ns/op 0 B/op 0 allocs/op +// BenchmarkInsertSimplestEmptyVectors/100-12 1000 6.800 ns/op 0 B/op 0 allocs/op // PASS // ok // nolint:lll,dupl // it's OK @@ -755,20 +615,8 @@ func BenchmarkInsertSimplestEmptyVectors(b *testing.B) { var writeAPI clickhousebuffer.Writer b.ResetTimer() - b.Run("10000000", func(b *testing.B) { - client.Options().SetBatchSize(10000000) - writeAPI = client.Writer( - cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), - cxmem.NewBuffer(client.Options().BatchSize()), - ) - b.ResetTimer() - for i := 0; i < b.N; i++ { - insertEmptyVectors(writeAPI, 10000000, b) - } - }) - b.Run("1000000", func(b *testing.B) { - client.Options().SetBatchSize(1000000) + client.Options().SetBatchSize(1000001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), @@ -780,7 +628,7 @@ func BenchmarkInsertSimplestEmptyVectors(b *testing.B) { }) b.Run("100000", func(b *testing.B) { - client.Options().SetBatchSize(100000) + client.Options().SetBatchSize(100001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), @@ -792,7 +640,7 @@ func BenchmarkInsertSimplestEmptyVectors(b *testing.B) { }) b.Run("10000", func(b *testing.B) { - client.Options().SetBatchSize(10000) + client.Options().SetBatchSize(10001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), @@ -804,7 +652,7 @@ func BenchmarkInsertSimplestEmptyVectors(b *testing.B) { }) b.Run("1000", func(b *testing.B) { - client.Options().SetBatchSize(1000) + client.Options().SetBatchSize(1001) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), @@ -816,7 +664,7 @@ func BenchmarkInsertSimplestEmptyVectors(b *testing.B) { }) b.Run("100", func(b *testing.B) { - client.Options().SetBatchSize(100) + client.Options().SetBatchSize(101) writeAPI = client.Writer( cx.NewView(tables.ExampleTableName(), tables.ExampleTableColumns()), cxmem.NewBuffer(client.Options().BatchSize()), @@ -839,6 +687,10 @@ func insertObjects(writeAPI clickhousebuffer.Writer, x int, b *testing.B) { object = &BenchTable{ID: 1} writeAPI.WriteRow(object) } + // for flush data + b.StopTimer() + writeAPI.WriteVector(cx.Vector{}) + b.StartTimer() } func insertVectors(writeAPI clickhousebuffer.Writer, x int, b *testing.B) { @@ -848,6 +700,10 @@ func insertVectors(writeAPI clickhousebuffer.Writer, x int, b *testing.B) { vector = cx.Vector{1, "", ""} writeAPI.WriteVector(vector) } + // for flush data + b.StopTimer() + writeAPI.WriteVector(cx.Vector{}) + b.StartTimer() } func insertEmptyVectors(writeAPI clickhousebuffer.Writer, x int, b *testing.B) { @@ -855,6 +711,10 @@ func insertEmptyVectors(writeAPI clickhousebuffer.Writer, x int, b *testing.B) { for i := 0; i < x; i++ { writeAPI.WriteVector(cx.Vector{}) } + // for flush data + b.StopTimer() + writeAPI.WriteVector(cx.Vector{}) + b.StartTimer() } func insertPreAllocatedObjects(writeAPI clickhousebuffer.Writer, x int, b *testing.B) { @@ -866,6 +726,13 @@ func insertPreAllocatedObjects(writeAPI clickhousebuffer.Writer, x int, b *testi for i := range objects { writeAPI.WriteRow(objects[i]) } + // for flush data + b.StopTimer() + // nolint:staticcheck // it's OK + objects = objects[:0] + objects = nil + writeAPI.WriteVector(cx.Vector{}) + b.StartTimer() } func insertPreAllocatedVectors(writeAPI clickhousebuffer.Writer, x int, b *testing.B) { @@ -877,4 +744,11 @@ func insertPreAllocatedVectors(writeAPI clickhousebuffer.Writer, x int, b *testi for i := range vectors { writeAPI.WriteVector(vectors[i]) } + // for flush data + b.StopTimer() + // nolint:staticcheck // it's OK + vectors = vectors[:0] + vectors = nil + writeAPI.WriteVector(cx.Vector{}) + b.StartTimer() }