feat: add watcher for record code excution time

This commit is contained in:
dudaodong committed 2022-01-01 19:56:15 +08:00
1 parent ed4acc1c67
commit d4f49af2ad
3 files changed
+63

No files matched your search

+32
View File
@@ -0,0 +1,32 @@
package function
import (
"testing"
)
func TestWatcher(t *testing.T) {
w := &Watcher{}
w.Start()
longRunningTask()
if !w.excuting {
t.FailNow()
}
w.Stop()
eapsedTime := w.GetElapsedTime().Milliseconds()
t.Log("Elapsed Time (milsecond)", eapsedTime)
if w.excuting {
t.FailNow()
}
}
func longRunningTask() {
var slice []int64
for i := 0; i < 10000000; i++ {
slice = append(slice, int64(i))
}
}