@@ -34,6 +34,9 @@ import (
3434var _ statefulsyncer.Logger = (* Logger )(nil )
3535
3636const (
37+ // TimeElapsedCounter tracks the total time elapsed in seconds.
38+ TimeElapsedCounter = "time_elapsed"
39+
3740 // blockStreamFile contains the stream of processed
3841 // blocks and whether they were added or removed.
3942 blockStreamFile = "blocks.txt"
@@ -107,6 +110,17 @@ func (l *Logger) LogDataStats(ctx context.Context) error {
107110 return nil
108111 }
109112
113+ elapsedTime , err := l .CounterStorage .Get (ctx , TimeElapsedCounter )
114+ if err != nil {
115+ return fmt .Errorf ("%w cannot get elapsed time" , err )
116+ }
117+
118+ if elapsedTime .Sign () == 0 { // wait for at least some elapsed time
119+ return nil
120+ }
121+
122+ blocksPerSecond := new (big.Int ).Div (blocks , elapsedTime )
123+
110124 orphans , err := l .CounterStorage .Get (ctx , storage .OrphanCounter )
111125 if err != nil {
112126 return fmt .Errorf ("%w cannot get orphan counter" , err )
@@ -133,9 +147,10 @@ func (l *Logger) LogDataStats(ctx context.Context) error {
133147 }
134148
135149 statsMessage := fmt .Sprintf (
136- "[STATS] Blocks: %s (Orphaned: %s) Transactions: %s Operations: %s" ,
150+ "[STATS] Blocks: %s (Orphaned: %s, Rate: %s/sec ) Transactions: %s Operations: %s" ,
137151 blocks .String (),
138152 orphans .String (),
153+ blocksPerSecond .String (),
139154 txs .String (),
140155 ops .String (),
141156 )
0 commit comments