Skip to content

Commit fe40378

Browse files
committed
mod: update time track utils
1 parent 1039fa5 commit fe40378

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

internal/middleware/plugins/http_proxy.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func (m *HttpProxyMiddleware) OnProcess(session *rpc.Session) error {
8686
utils.TimeTrack(startTime, session.NodeName)
8787
}()
8888

89-
log.Debug("relay rpc -> "+session.RpcMethod(), "sid", session.SId(), "node", session.NodeName, "isTx", session.IsWriteRpcMethod, "tries", session.Tries)
89+
//log.Debug("relay rpc -> "+session.RpcMethod(), "sid", session.SId(), "node", session.NodeName, "isTx", session.IsWriteRpcMethod, "tries", session.Tries)
9090

9191
if _, ok := m.disableEndpoints.Get(session.NodeName); ok {
9292
log.Debug("disabled endpoint", "node", session.NodeName)

pkg/utils/misc.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@ import (
88
func TimeTrack(start time.Time, name string) {
99
elapsed := time.Since(start)
1010

11-
// calculate hours, minutes, and seconds
11+
// calculate hours, minutes, seconds, and milliseconds
1212
hours := int(elapsed.Hours())
1313
minutes := int(elapsed.Minutes()) % 60
1414
seconds := int(elapsed.Seconds()) % 60
15+
milliseconds := int(elapsed.Milliseconds()) % 1000
1516

16-
// build the formatted time string
1717
var formattedTime string
1818
if hours > 0 {
1919
formattedTime += fmt.Sprintf("%d hours, ", hours)
2020
}
2121
if minutes > 0 {
2222
formattedTime += fmt.Sprintf("%d minutes, ", minutes)
2323
}
24-
formattedTime += fmt.Sprintf("%d seconds", seconds)
24+
if seconds > 0 {
25+
formattedTime += fmt.Sprintf("%d seconds, ", seconds)
26+
}
27+
formattedTime += fmt.Sprintf("%d ms", milliseconds)
2528

2629
fmt.Printf("%s took: %s\n", name, formattedTime)
2730
}

0 commit comments

Comments
 (0)