Browse Source

benchmark: update for new stm interface

Anthony Romano 9 years ago
parent
commit
13420b33a0
1 changed files with 10 additions and 7 deletions
  1. 10 7
      tools/benchmark/cmd/stm.go

+ 10 - 7
tools/benchmark/cmd/stm.go

@@ -41,20 +41,21 @@ var stmCmd = &cobra.Command{
 type stmApply func(v3sync.STM) error
 type stmApply func(v3sync.STM) error
 
 
 var (
 var (
-	stmIsolation    string
+	stmIsolation string
+	stmIso       v3sync.Isolation
+
 	stmTotal        int
 	stmTotal        int
 	stmKeysPerTxn   int
 	stmKeysPerTxn   int
 	stmKeyCount     int
 	stmKeyCount     int
 	stmValSize      int
 	stmValSize      int
 	stmWritePercent int
 	stmWritePercent int
 	stmMutex        bool
 	stmMutex        bool
-	mkSTM           func(context.Context, *v3.Client, func(v3sync.STM) error) (*v3.TxnResponse, error)
 )
 )
 
 
 func init() {
 func init() {
 	RootCmd.AddCommand(stmCmd)
 	RootCmd.AddCommand(stmCmd)
 
 
-	stmCmd.Flags().StringVar(&stmIsolation, "isolation", "r", "Read Committed (c), Repeatable Reads (r), or Serializable (s)")
+	stmCmd.Flags().StringVar(&stmIsolation, "isolation", "r", "Read Committed (c), Repeatable Reads (r), Serializable (s), or Snapshot (ss)")
 	stmCmd.Flags().IntVar(&stmKeyCount, "keys", 1, "Total unique keys accessible by the benchmark")
 	stmCmd.Flags().IntVar(&stmKeyCount, "keys", 1, "Total unique keys accessible by the benchmark")
 	stmCmd.Flags().IntVar(&stmTotal, "total", 10000, "Total number of completed STM transactions")
 	stmCmd.Flags().IntVar(&stmTotal, "total", 10000, "Total number of completed STM transactions")
 	stmCmd.Flags().IntVar(&stmKeysPerTxn, "keys-per-txn", 1, "Number of keys to access per transaction")
 	stmCmd.Flags().IntVar(&stmKeysPerTxn, "keys-per-txn", 1, "Number of keys to access per transaction")
@@ -81,11 +82,13 @@ func stmFunc(cmd *cobra.Command, args []string) {
 
 
 	switch stmIsolation {
 	switch stmIsolation {
 	case "c":
 	case "c":
-		mkSTM = v3sync.NewSTMReadCommitted
+		stmIso = v3sync.ReadCommitted
 	case "r":
 	case "r":
-		mkSTM = v3sync.NewSTMRepeatable
+		stmIso = v3sync.RepeatableReads
 	case "s":
 	case "s":
-		mkSTM = v3sync.NewSTMSerializable
+		stmIso = v3sync.Serializable
+	case "ss":
+		stmIso = v3sync.Snapshot
 	default:
 	default:
 		fmt.Fprintln(os.Stderr, cmd.Usage())
 		fmt.Fprintln(os.Stderr, cmd.Usage())
 		os.Exit(1)
 		os.Exit(1)
@@ -155,7 +158,7 @@ func doSTM(client *v3.Client, requests <-chan stmApply, results chan<- report.Re
 		if m != nil {
 		if m != nil {
 			m.Lock(context.TODO())
 			m.Lock(context.TODO())
 		}
 		}
-		_, err := mkSTM(context.TODO(), client, applyf)
+		_, err := v3sync.NewSTM(client, applyf, v3sync.WithIsolation(stmIso))
 		if m != nil {
 		if m != nil {
 			m.Unlock(context.TODO())
 			m.Unlock(context.TODO())
 		}
 		}