If you are timing so short operations that the overhead is 1-2%, just time every 1000 calls - reduces the overhead to a minimum. Normally makes no difference if the operations are that short. Similar to how benchmarking works - time the total and divide by the number of operations.
> On Apr 28, 2021, at 10:04 PM, Pure White <wu.purewh...@gmail.com> wrote: > > > Hello, > We are doing heavily tracing, and for each func we need to get the time, so > that’s why I’d like to optimize this. > 在 2021年4月29日 +0800 AM12:11,Ian Lance Taylor <i...@golang.org>,写道: >> In the meantime we both sent speedups for time.Now. I measured >> time.Now as taking about 30 nanoseconds per call before the speedup, >> and you measured it as taking about 40 nanoseconds per call before the >> speedup. That makes me wonder about your code: if a 40 nanosecond >> function is taking 1% to 2% of your execution time, then if your >> program is CPU bound you must be calling it a truly extraordinary >> number of times. >> >> Ian > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/golang-nuts/3d782712-0a1f-4697-9fe6-e491c17a5b5f%40Spark. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4ECCDF1B-5AD2-477C-9543-89DB79FB1DFB%40ix.netcom.com.