add arguments

pull/69/head
Richard Liu 6 years ago
parent ace4559ce5
commit 0c5e80cf6e
  1. 9
      client/txgen/main.go

@ -33,6 +33,7 @@ type txGenSettings struct {
numOfAddress int numOfAddress int
crossShard bool crossShard bool
maxNumTxsPerBatch int maxNumTxsPerBatch int
crossShardRatio int
} }
var ( var (
@ -115,7 +116,7 @@ UTXOLOOP:
randNum := rand.Intn(100) randNum := rand.Intn(100)
if setting.crossShard && randNum < 30 { // 1/3 cross shard transactions: add another txinput from another shard if setting.crossShard && randNum < setting.crossShardRatio { // 30% cross shard transactions: add another txinput from another shard
generateCrossShardTx(&txInfo) generateCrossShardTx(&txInfo)
} else { } else {
generateSingleShardTx(&txInfo) generateSingleShardTx(&txInfo)
@ -234,8 +235,9 @@ func main() {
maxNumTxsPerBatch := flag.Int("max_num_txs_per_batch", 100000, "number of transactions to send per message") maxNumTxsPerBatch := flag.Int("max_num_txs_per_batch", 100000, "number of transactions to send per message")
logFolder := flag.String("log_folder", "latest", "the folder collecting the logs of this execution") logFolder := flag.String("log_folder", "latest", "the folder collecting the logs of this execution")
numSubset := flag.Int("numSubset", 3, "the number of subsets of utxos to process separately") numSubset := flag.Int("numSubset", 3, "the number of subsets of utxos to process separately")
duration := flag.Int("duration", 60, "duration of the tx generation in second") duration := flag.Int("duration", 60, "duration of the tx generation in second. If it's negative, the experiment runs forever.")
versionFlag := flag.Bool("version", false, "Output version info") versionFlag := flag.Bool("version", false, "Output version info")
crossShardRatio := flag.Int("cross_shard_ratio", 30, "The percentage of cross shard transactions.")
flag.Parse() flag.Parse()
if *versionFlag { if *versionFlag {
@ -251,6 +253,7 @@ func main() {
// Do cross shard tx if there are more than one shard // Do cross shard tx if there are more than one shard
setting.crossShard = len(shardIds) > 1 setting.crossShard = len(shardIds) > 1
setting.maxNumTxsPerBatch = *maxNumTxsPerBatch setting.maxNumTxsPerBatch = *maxNumTxsPerBatch
setting.crossShardRatio = *crossShardRatio
// TODO(Richard): refactor this chuck to a single method // TODO(Richard): refactor this chuck to a single method
// Setup a logger to stdout and log file. // Setup a logger to stdout and log file.
@ -312,7 +315,7 @@ func main() {
batchCounter := 0 batchCounter := 0
for true { for true {
t := time.Now() t := time.Now()
if t.Sub(start).Seconds() >= totalTime { if totalTime > 0 && t.Sub(start).Seconds() >= totalTime {
log.Debug("Generator timer ended.", "duration", (int(t.Sub(start))), "startTime", start, "totalTime", totalTime) log.Debug("Generator timer ended.", "duration", (int(t.Sub(start))), "startTime", start, "totalTime", totalTime)
break break
} }

Loading…
Cancel
Save