-
Notifications
You must be signed in to change notification settings - Fork 6
Time Measuring
Roman edited this page Jan 18, 2023
·
1 revision
Gotaskr provides some statistics while running and after running the tasks.
Sometimes, you want to measure the runtime for only a part of a task. That's where individual measuring points come into play.
Here is an example:
gotaskr.Task("Task", func() error {
gotaskr.MeasureTime("Test1", func() error {
time.Sleep(time.Duration(2 * time.Second))
return nil
})
gotaskr.MeasureTime("Test2", func() error {
time.Sleep(time.Duration(1 * time.Second))
return nil
})
gotaskr.MeasureTime("Test3", func() error {
time.Sleep(time.Duration(3 * time.Second))
return nil
})
return nil
})
Here we use three individual parts that should be measured inside a task. Here is what the statistics of this task look like:
Task Exit Code Duration
--------------------------------------------------------------------------------
Hello 0 00:00:06.024920
├─ Test1 00:00:02.007351
├─ Test2 00:00:01.014573
└─ Test3 00:00:03.002994
--------------------------------------------------------------------------------
Total 00:00:06.024920