Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 55 additions & 55 deletions config/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ import (

// Settings holds all CLI-configurable parameters
type Settings struct {
Workers int `json:"workers,omitempty"`
TPS float64 `json:"tps,omitempty"`
StatsInterval Duration `json:"statsInterval,omitempty"`
BufferSize int `json:"bufferSize,omitempty"`
DryRun bool `json:"dryRun,omitempty"`
Debug bool `json:"debug,omitempty"`
TrackReceipts bool `json:"trackReceipts,omitempty"`
TrackBlocks bool `json:"trackBlocks,omitempty"`
TrackUserLatency bool `json:"trackUserLatency,omitempty"`
Prewarm bool `json:"prewarm,omitempty"`
RampUp bool `json:"rampUp,omitempty"`
ReportPath string `json:"reportPath,omitempty"`
TxsDir string `json:"txsDir,omitempty"`
TasksPerEndpoint int `json:"workers,omitempty"`
TPS float64 `json:"tps,omitempty"`
StatsInterval Duration `json:"statsInterval,omitempty"`
BufferSize int `json:"bufferSize,omitempty"`
DryRun bool `json:"dryRun,omitempty"`
Debug bool `json:"debug,omitempty"`
TrackReceipts bool `json:"trackReceipts,omitempty"`
TrackBlocks bool `json:"trackBlocks,omitempty"`
TrackUserLatency bool `json:"trackUserLatency,omitempty"`
Prewarm bool `json:"prewarm,omitempty"`
RampUp bool `json:"rampUp,omitempty"`
ReportPath string `json:"reportPath,omitempty"`
TxsDir string `json:"txsDir,omitempty"`
TargetGas uint64 `json:"targetGas,omitempty"`
NumBlocksToWrite int `json:"numBlocksToWrite,omitempty"`
PostSummaryFlushDelay Duration `json:"postSummaryFlushDelay,omitempty"`
Expand All @@ -33,19 +33,19 @@ type Settings struct {
// DefaultSettings returns the default configuration values
func DefaultSettings() Settings {
return Settings{
Workers: 1,
TPS: 0.0,
StatsInterval: Duration(10 * time.Second),
BufferSize: 1000,
DryRun: false,
Debug: false,
TrackReceipts: false,
TrackBlocks: false,
TrackUserLatency: false,
Prewarm: false,
RampUp: false,
ReportPath: "",
TxsDir: "",
TasksPerEndpoint: 1,
TPS: 0.0,
StatsInterval: Duration(10 * time.Second),
BufferSize: 1000,
DryRun: false,
Debug: false,
TrackReceipts: false,
TrackBlocks: false,
TrackUserLatency: false,
Prewarm: false,
RampUp: false,
ReportPath: "",
TxsDir: "",
TargetGas: 10_000_000,
NumBlocksToWrite: 100,
PostSummaryFlushDelay: Duration(25 * time.Second),
Expand All @@ -56,19 +56,19 @@ func DefaultSettings() Settings {
func InitializeViper(cmd *cobra.Command) error {
// Bind flags to viper with error checking
flagBindings := map[string]string{
"statsInterval": "stats-interval",
"bufferSize": "buffer-size",
"tps": "tps",
"dryRun": "dry-run",
"debug": "debug",
"trackReceipts": "track-receipts",
"trackBlocks": "track-blocks",
"prewarm": "prewarm",
"trackUserLatency": "track-user-latency",
"workers": "workers",
"rampUp": "ramp-up",
"reportPath": "report-path",
"txsDir": "txs-dir",
"statsInterval": "stats-interval",
"bufferSize": "buffer-size",
"tps": "tps",
"dryRun": "dry-run",
"debug": "debug",
"trackReceipts": "track-receipts",
"trackBlocks": "track-blocks",
"prewarm": "prewarm",
"trackUserLatency": "track-user-latency",
"workers": "workers",
"rampUp": "ramp-up",
"reportPath": "report-path",
"txsDir": "txs-dir",
"targetGas": "target-gas",
"numBlocksToWrite": "num-blocks-to-write",
"postSummaryFlushDelay": "post-summary-flush-delay",
Expand All @@ -91,7 +91,7 @@ func InitializeViper(cmd *cobra.Command) error {
viper.SetDefault("trackBlocks", defaults.TrackBlocks)
viper.SetDefault("prewarm", defaults.Prewarm)
viper.SetDefault("trackUserLatency", defaults.TrackUserLatency)
viper.SetDefault("workers", defaults.Workers)
viper.SetDefault("workers", defaults.TasksPerEndpoint)
viper.SetDefault("rampUp", defaults.RampUp)
viper.SetDefault("reportPath", defaults.ReportPath)
viper.SetDefault("txsDir", defaults.TxsDir)
Expand Down Expand Up @@ -122,21 +122,21 @@ func LoadSettings(settings *Settings) error {
}

// ResolveSettings gets the final resolved settings from Viper
func ResolveSettings() Settings {
return Settings{
Workers: viper.GetInt("workers"),
TPS: viper.GetFloat64("tps"),
StatsInterval: Duration(viper.GetDuration("statsInterval")),
BufferSize: viper.GetInt("bufferSize"),
DryRun: viper.GetBool("dryRun"),
Debug: viper.GetBool("debug"),
TrackReceipts: viper.GetBool("trackReceipts"),
TrackBlocks: viper.GetBool("trackBlocks"),
TrackUserLatency: viper.GetBool("trackUserLatency"),
Prewarm: viper.GetBool("prewarm"),
RampUp: viper.GetBool("rampUp"),
ReportPath: viper.GetString("reportPath"),
TxsDir: viper.GetString("txsDir"),
func ResolveSettings() *Settings {
return &Settings{
TasksPerEndpoint: viper.GetInt("workers"),
TPS: viper.GetFloat64("tps"),
StatsInterval: Duration(viper.GetDuration("statsInterval")),
BufferSize: viper.GetInt("bufferSize"),
DryRun: viper.GetBool("dryRun"),
Debug: viper.GetBool("debug"),
TrackReceipts: viper.GetBool("trackReceipts"),
TrackBlocks: viper.GetBool("trackBlocks"),
TrackUserLatency: viper.GetBool("trackUserLatency"),
Prewarm: viper.GetBool("prewarm"),
RampUp: viper.GetBool("rampUp"),
ReportPath: viper.GetString("reportPath"),
TxsDir: viper.GetString("txsDir"),
TargetGas: viper.GetUint64("targetGas"),
NumBlocksToWrite: viper.GetInt("numBlocksToWrite"),
PostSummaryFlushDelay: Duration(viper.GetDuration("postSummaryFlushDelay")),
Expand Down
28 changes: 14 additions & 14 deletions config/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestArgumentPrecedence(t *testing.T) {

// Verify expectations
require.Equal(t, tt.expectedStats, settings.StatsInterval.ToDuration(), "StatsInterval: expected %v, got %v", tt.expectedStats, settings.StatsInterval.ToDuration())
require.Equal(t, tt.expectedWorkers, settings.Workers, "Workers: expected %d, got %d", tt.expectedWorkers, settings.Workers)
require.Equal(t, tt.expectedWorkers, settings.TasksPerEndpoint, "TasksPerEndpoint: expected %d, got %d", tt.expectedWorkers, settings.TasksPerEndpoint)
require.Equal(t, tt.expectedTPS, settings.TPS, "TPS: expected %f, got %f", tt.expectedTPS, settings.TPS)
})
}
Expand All @@ -125,19 +125,19 @@ func TestDefaultSettings(t *testing.T) {
defaults := DefaultSettings()

expected := Settings{
Workers: 1,
TPS: 0.0,
StatsInterval: Duration(10 * time.Second),
BufferSize: 1000,
DryRun: false,
Debug: false,
TrackReceipts: false,
TrackBlocks: false,
TrackUserLatency: false,
Prewarm: false,
RampUp: false,
ReportPath: "",
TxsDir: "",
TasksPerEndpoint: 1,
TPS: 0.0,
StatsInterval: Duration(10 * time.Second),
BufferSize: 1000,
DryRun: false,
Debug: false,
TrackReceipts: false,
TrackBlocks: false,
TrackUserLatency: false,
Prewarm: false,
RampUp: false,
ReportPath: "",
TxsDir: "",
TargetGas: 10_000_000,
NumBlocksToWrite: 100,
PostSummaryFlushDelay: Duration(25 * time.Second),
Expand Down
5 changes: 2 additions & 3 deletions generator/scenario.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ type scenarioGenerator struct {
mu sync.RWMutex
}

func NewScenarioGenerator(accounts types.AccountPool,
txg scenarios.TxGenerator) Generator {
func NewScenarioGenerator(accounts types.AccountPool, txg scenarios.TxGenerator) Generator {
return &scenarioGenerator{
scenario: txg,
accountPool: accounts,
Expand All @@ -23,7 +22,7 @@ func NewScenarioGenerator(accounts types.AccountPool,

func (g *scenarioGenerator) GenerateN(n int) []*types.LoadTx {
result := make([]*types.LoadTx, 0, n)
for i := 0; i < n; i++ {
for range n {
if tx, ok := g.Generate(); ok {
result = append(result, tx)
} else {
Expand Down
Loading
Loading