@@ -22,16 +22,17 @@ import (
2222)
2323
2424var (
25- configFile string
26- statsInterval time.Duration
27- bufferSize int
28- tps float64
29- dryRun bool
30- debug bool
31- workers int
32- trackReceipts bool
33- trackBlocks bool
34- prewarm bool
25+ configFile string
26+ statsInterval time.Duration
27+ bufferSize int
28+ tps float64
29+ dryRun bool
30+ debug bool
31+ workers int
32+ trackReceipts bool
33+ trackBlocks bool
34+ prewarm bool
35+ trackUserLatency bool
3536)
3637
3738var rootCmd = & cobra.Command {
@@ -62,6 +63,7 @@ func init() {
6263 rootCmd .Flags ().BoolVarP (& trackReceipts , "track-receipts" , "" , false , "Track receipts" )
6364 rootCmd .Flags ().BoolVarP (& trackBlocks , "track-blocks" , "" , false , "Track blocks" )
6465 rootCmd .Flags ().BoolVarP (& prewarm , "prewarm" , "" , false , "Prewarm accounts with self-transactions" )
66+ rootCmd .Flags ().BoolVarP (& trackUserLatency , "track-user-latency" , "" , false , "Track user latency" )
6567 rootCmd .Flags ().IntVarP (& workers , "workers" , "w" , 1 , "Number of workers" )
6668
6769 if err := rootCmd .MarkFlagRequired ("config" ); err != nil {
@@ -83,7 +85,7 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
8385 // Parse the config file into a config.LoadConfig struct
8486 cfg , err := loadConfig (configFile )
8587 if err != nil {
86- return fmt .Errorf ("Failed to load config: %w" , err )
88+ return fmt .Errorf ("failed to load config: %w" , err )
8789 }
8890
8991 log .Printf ("🚀 Starting Sei Chain Load Test v2" )
@@ -109,6 +111,9 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
109111 if prewarm {
110112 log .Printf ("📝 Prewarm: enabled" )
111113 }
114+ if trackUserLatency {
115+ log .Printf ("📝 Track user latency: enabled" )
116+ }
112117 log .Println ()
113118
114119 // Enable mock deployment in dry-run mode
@@ -124,13 +129,13 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
124129 // Create the generator from the config struct
125130 gen , err := generator .NewConfigBasedGenerator (cfg )
126131 if err != nil {
127- return fmt .Errorf ("Failed to create generator: %w" , err )
132+ return fmt .Errorf ("failed to create generator: %w" , err )
128133 }
129134
130135 // Create the sender from the config struct
131136 snd , err := sender .NewShardedSender (cfg , bufferSize , workers )
132137 if err != nil {
133- return fmt .Errorf ("Failed to create sender: %w" , err )
138+ return fmt .Errorf ("failed to create sender: %w" , err )
134139 }
135140
136141 // Create and start block collector if endpoints are available
@@ -143,6 +148,14 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
143148 })
144149 }
145150
151+ // Create and start user latency tracker if endpoints are available
152+ if len (cfg .Endpoints ) > 0 && trackUserLatency {
153+ userLatencyTracker := stats .NewUserLatencyTracker (statsInterval )
154+ s .SpawnBgNamed ("user latency tracker" , func () error {
155+ return userLatencyTracker .Run (ctx , cfg .Endpoints [0 ])
156+ })
157+ }
158+
146159 // Enable dry-run mode in sender if specified
147160 if dryRun {
148161 snd .SetDryRun (true )
@@ -187,7 +200,7 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
187200 // Perform prewarming if enabled (before starting logger to avoid logging prewarm transactions)
188201 if prewarm {
189202 if err := dispatcher .Prewarm (ctx ); err != nil {
190- return fmt .Errorf ("Failed to prewarm accounts: %w" , err )
203+ return fmt .Errorf ("failed to prewarm accounts: %w" , err )
191204 }
192205 }
193206
@@ -216,6 +229,9 @@ func runLoadTest(ctx context.Context, cmd *cobra.Command, args []string) error {
216229 if trackBlocks {
217230 log .Printf ("📝 Track blocks mode: Block data will be collected" )
218231 }
232+ if trackUserLatency {
233+ log .Printf ("📝 Track user latency mode: User latency will be tracked" )
234+ }
219235 log .Print (strings .Repeat ("=" , 60 ))
220236
221237 // Main loop - wait for shutdown signal
@@ -240,7 +256,7 @@ func loadConfig(filename string) (*config.LoadConfig, error) {
240256
241257 var cfg config.LoadConfig
242258 if err := json .Unmarshal (data , & cfg ); err != nil {
243- return nil , fmt .Errorf ("failed to parse config JSON : %w" , err )
259+ return nil , fmt .Errorf ("failed to parse config json : %w" , err )
244260 }
245261
246262 // Validate configuration
0 commit comments