rcrowley / go-metrics

Go port of Coda Hale's Metrics library
Other
3.43k stars 493 forks source link

optimize the SampleXXX function and fixes #249 #261

Open lrita opened 4 years ago

lrita commented 4 years ago

Hi @rcrowley, @mihasya , could you have time to review this patch?

name                             old time/op  new time/op  delta
SampleCalc4K/SampleSum-4         2.07µs ± 6%  0.25µs ± 3%  -88.07%  (p=0.100 n=3+3)
SampleCalc4K/SampleMax-4         2.79µs ± 4%  0.71µs ± 1%  -74.50%  (p=0.100 n=3+3)
SampleCalc4K/SampleMin-4         2.73µs ± 1%  0.70µs ± 1%  -74.34%  (p=0.100 n=3+3)
SampleCalc4K/SampleMean-4        1.99µs ± 2%  0.24µs ± 1%  -87.73%  (p=0.100 n=3+3)
SampleCalc4K/SampleStdDev-4      6.16µs ± 1%  4.09µs ± 4%  -33.52%  (p=0.100 n=3+3)
SampleCalc4K/SampleVariance-4    6.10µs ± 2%  4.03µs ± 2%  -33.93%  (p=0.100 n=3+3)
SampleCalc4K/SamplePercentile-4   222µs ± 1%   215µs ± 1%   -2.78%  (p=0.100 n=3+3)
lrita commented 4 years ago

Hi @rcrowley, @mihasya , could you have time to review this patch?

Making it support go1.4-go1.12 already and remove the go1.3 support.

lrita commented 4 years ago

I think these advices are very useful. I will modify this pr in few days.

lrita commented 4 years ago

Hi @mihasya , Re-commit by above good advices.