github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ccl/workloadccl/bench_test.go (about) 1 // Copyright 2019 The Cockroach Authors. 2 // 3 // Licensed as a CockroachDB Enterprise file under the Cockroach Community 4 // License (the "License"); you may not use this file except in compliance with 5 // the License. You may obtain a copy of the License at 6 // 7 // https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt 8 9 package workloadccl_test 10 11 import ( 12 "context" 13 "testing" 14 15 "github.com/cockroachdb/cockroach/pkg/base" 16 _ "github.com/cockroachdb/cockroach/pkg/ccl" 17 "github.com/cockroachdb/cockroach/pkg/ccl/workloadccl" 18 "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" 19 "github.com/cockroachdb/cockroach/pkg/testutils/sqlutils" 20 "github.com/cockroachdb/cockroach/pkg/workload" 21 "github.com/cockroachdb/cockroach/pkg/workload/tpcc" 22 "github.com/stretchr/testify/require" 23 ) 24 25 func benchmarkImportFixture(b *testing.B, gen workload.Generator) { 26 ctx := context.Background() 27 28 var bytes int64 29 b.StopTimer() 30 for i := 0; i < b.N; i++ { 31 s, db, _ := serverutils.StartServer(b, base.TestServerArgs{UseDatabase: `d`}) 32 sqlDB := sqlutils.MakeSQLRunner(db) 33 sqlDB.Exec(b, `CREATE DATABASE d`) 34 35 b.StartTimer() 36 const filesPerNode = 1 37 const noInjectStats, csvServer = false, `` 38 importBytes, err := workloadccl.ImportFixture( 39 ctx, db, gen, `d`, filesPerNode, noInjectStats, csvServer, 40 ) 41 require.NoError(b, err) 42 bytes += importBytes 43 b.StopTimer() 44 45 s.Stopper().Stop(ctx) 46 } 47 b.SetBytes(bytes / int64(b.N)) 48 } 49 50 func BenchmarkImportFixture(b *testing.B) { 51 if testing.Short() { 52 b.Skip("skipping long benchmark") 53 } 54 55 b.Run(`tpcc/warehouses=1`, func(b *testing.B) { 56 benchmarkImportFixture(b, tpcc.FromWarehouses(1)) 57 }) 58 }