github.com/loov/hrtime@v1.0.3/now.go (about) 1 package hrtime 2 3 import ( 4 "time" 5 ) 6 7 var nanoOverhead time.Duration 8 9 // Overhead returns approximate overhead for a call to Now() or Since() 10 func Overhead() time.Duration { return nanoOverhead } 11 12 // Since returns time.Duration since start 13 func Since(start time.Duration) time.Duration { return Now() - start } 14 15 func calculateNanosOverhead() { 16 start := Now() 17 for i := 0; i < calibrationCalls; i++ { 18 Now() 19 } 20 stop := Now() 21 nanoOverhead = (stop - start) / (calibrationCalls + 1) 22 }