Skip to content

Commit

Permalink
benchdb: bootstrap session. (pingcap#2726)
Browse files Browse the repository at this point in the history
* benchdb: use random string for every row
  • Loading branch information
coocood authored and zimulala committed Feb 24, 2017
1 parent b3a5732 commit a1a24e8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions cmd/benchdb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,11 @@ var (
}, "|"), "jobs to run")
)

var blobString string

func main() {
flag.Parse()
flag.PrintDefaults()
log.SetLevelByString(*logLevel)
tidb.RegisterStore("tikv", tikv.Driver{})
blobString = strings.Repeat("0", *blobSize)
ut := newBenchDB()
works := strings.Split(*runJobs, "|")
for _, v := range works {
Expand Down Expand Up @@ -92,6 +89,7 @@ type benchDB struct {
func newBenchDB() *benchDB {
// Create TiKV store and disable GC as we will trigger GC manually.
store, err := tidb.NewStore("tikv://" + *addr + "?disableGC=true")
tidb.BootstrapSession(store)
if err != nil {
log.Fatal(err)
}
Expand Down Expand Up @@ -225,12 +223,14 @@ func (ut *benchDB) insertRows(spec string) {
id := start
ut.runCountTimes("insert", loopCount, func() {
ut.mustExec("begin")
buf := make([]byte, *blobSize/2)
for i := 0; i < *batchSize; i++ {
if id == end {
break
}
insetQuery := fmt.Sprintf("insert %s (id, name, data) values (%d, '%d', '%s')",
*tableName, id, id, blobString)
rand.Read(buf)
insetQuery := fmt.Sprintf("insert %s (id, name, data) values (%d, '%d', '%x')",
*tableName, id, id, buf)
ut.mustExec(insetQuery)
id++
}
Expand Down

0 comments on commit a1a24e8

Please sign in to comment.