Import time and github.com/UedaTakeyuki/erapse and just call defer erapse.ShowErapsedTIme(time.Now())
at the beginning of the function you want to measure elapsed time, that it! Fx:
import (
"time"
"github.com/UedaTakeyuki/erapse"
)
func DoSomething(){
defer erapse.ShowErapsedTIme(time.Now())
The result is as follows:
eraps main.DoSomething: 1896985 μs
On Intel PC, The ShowErapsedTIme itself consumes several microseconds.
On RPi, this consumes several tens of microseconds.
See the go test -v -run Test_04
under the test folder for more details.
Due to my mother language being Japanese which doesn't have a difference in pronunciation between R and L, I carelessly misspelt it. ^^; By the time I noticed the mistake, I had already used it a lot, so it was hard to correct the spelling now, so I thought it was okay and left it as is. I'm sure there are many other typos and grammatical errors in the document I wrote, so please feel free to point them out. Thx!
C++ version is available at https://github.com/UedaTakeyuki/elapse.
- 2020.07.06 created from scratch
- 2024.05.31 add test, IsShow