master > master: code go, py - Anzeige von Metriken vereinheitlicht; start/stop unmittelbar um Ausführung des Algorithmus
This commit is contained in:
@@ -5,8 +5,10 @@ package metrics
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"ads/internal/core/utils"
|
||||
"ads/internal/types"
|
||||
)
|
||||
|
||||
@@ -22,10 +24,18 @@ var _tmr = types.NewTimer()
|
||||
* METHODS
|
||||
* ---------------------------------------------------------------- */
|
||||
|
||||
func RestartMetrics() {
|
||||
_tmr.Reset()
|
||||
func ResetMetrics() {
|
||||
_ctr_time.Reset()
|
||||
_ctr_space.Reset()
|
||||
_tmr.Reset()
|
||||
}
|
||||
|
||||
func StartMetrics() {
|
||||
_tmr.Start()
|
||||
}
|
||||
|
||||
func StopMetrics() {
|
||||
_tmr.Stop()
|
||||
}
|
||||
|
||||
func AddTimeCost(options ...int) {
|
||||
@@ -45,6 +55,22 @@ func GetSpaceCost() int {
|
||||
}
|
||||
|
||||
func GetTimeElapsed() time.Duration {
|
||||
_tmr.Stop()
|
||||
return _tmr.ElapsedTime()
|
||||
}
|
||||
|
||||
func GetTimeElapsedLongFormat() string {
|
||||
t := _tmr.ElapsedTime()
|
||||
h := utils.Floor(t.Hours())
|
||||
m := utils.Floor(t.Minutes()) - h*60
|
||||
s := t.Seconds() - float64(m*60)
|
||||
h_string := fmt.Sprintf("%v", h)
|
||||
for len(h_string) < 2 {
|
||||
h_string = "0" + h_string
|
||||
}
|
||||
m_string := fmt.Sprintf("%v", m)
|
||||
for len(m_string) < 2 {
|
||||
m_string = "0" + m_string
|
||||
}
|
||||
s_string := fmt.Sprintf("%f", s)
|
||||
return fmt.Sprintf("%[1]s:%[2]s:%[3]s", h_string, m_string, s_string)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user