1
0
mirror of https://github.com/charlienet/go-mixed.git synced 2025-07-18 08:32:40 +08:00

stopwatch

This commit is contained in:
2022-03-27 10:20:41 +08:00
parent 0f1949f531
commit 4344259190
2 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package stopwatch_test
import (
"testing"
"time"
"github.com/charlienet/go-mixed/stopwatch"
)
func TestWatch(t *testing.T) {
watch := stopwatch.StartNew()
time.Sleep(time.Second * 3)
t.Log("Elapsed:", watch.Elapsed())
t.Log("Elapsed:", watch.ElapsedMilliseconds())
t.Log("Elapsed:", watch.ElapsedMicroseconds())
t.Log("Elapsed:", watch.ElapsedNanoseconds())
time.Sleep(time.Second * 1)
t.Log("Elapsed:", watch.Elapsed())
watch.Restart()
t.Log("Elapsed:", watch.Elapsed())
time.Sleep(time.Second * 1)
t.Log("Elapsed:", watch.Elapsed())
watch.Reset()
watch.Restart()
}