Skip to content

Commit

Permalink
separate checks into run check and load check.
Browse files Browse the repository at this point in the history
Signed-off-by: mahjonp <[email protected]>
  • Loading branch information
mahjonp committed Nov 15, 2019
1 parent 1c9415a commit add799a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/go-tpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func openDB() {

func main() {
var rootCmd = &cobra.Command{
Use: "dbbench",
Use: "go-tpc",
Short: "Benchmark database with different workloads",
}

Expand Down
7 changes: 5 additions & 2 deletions cmd/go-tpc/misc.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,14 @@ func execute(ctx context.Context, w workload.Workloader, action string, index in
return err
}
}
return w.Prepare(ctx, index)
if err := w.Prepare(ctx, index); err != nil {
return nil
}
return w.Check(ctx, index, true)
case "cleanup":
return w.Cleanup(ctx, index)
case "check":
return w.Check(ctx, index)
return w.Check(ctx, index, false)
}

for i := 0; i < count; i++ {
Expand Down
2 changes: 1 addition & 1 deletion pkg/workload/workload.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ type Workloader interface {
Prepare(ctx context.Context, threadID int) error
Run(ctx context.Context, threadID int) error
Cleanup(ctx context.Context, threadID int) error
Check(ctx context.Context, threadID int) error
Check(ctx context.Context, threadID int, checkForLoad bool) error
}
13 changes: 12 additions & 1 deletion tpcc/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,20 @@ import (
)

// Check implements Workloader interface
func (w *Workloader) Check(ctx context.Context, threadID int) error {
func (w *Workloader) Check(ctx context.Context, threadID int, checkForLoad bool) error {
// refer 3.3.2
checks := []func(ctx context.Context, warehouse int) error{
w.checkCondition1,
w.checkCondition2,
w.checkCondition3,
w.checkCondition4,
}

loadChecks := []func(ctx context.Context, warehouse int) error{
w.checkCondition1,
w.checkCondition2,
w.checkCondition3,
w.checkCondition4,
w.checkCondition5,
w.checkCondition6,
w.checkCondition7,
Expand All @@ -23,6 +30,10 @@ func (w *Workloader) Check(ctx context.Context, threadID int) error {
w.checkCondition12,
}

if checkForLoad {
checks = loadChecks
}

for i := threadID % w.cfg.Threads; i < w.cfg.Warehouses; i += w.cfg.Threads {
warehouse := i%w.cfg.Warehouses + 1
for i := 0; i < len(checks); i++ {
Expand Down

0 comments on commit add799a

Please sign in to comment.