go-metrics icon indicating copy to clipboard operation
go-metrics copied to clipboard

Defer

Open DAddYE opened this issue 11 years ago • 2 comments

Hi have you seen this: http://lk4d4.darth.io/posts/defer/ ?

I benchmarked it again against go 1.3.1 and I still see a quite big difference

BenchmarkPut       50000         38259 ns/op
BenchmarkPutDefer      50000         63552 ns/op
BenchmarkGet       50000         41260 ns/op
BenchmarkGetDefer      10000        107873 ns/op

Basically defer seems not yet fully optimized.

Since go-metrics have different short functions with defer probably removing them could help in measuring with more precision.

What do you think?

DAddYE avatar Aug 31 '14 03:08 DAddYE

Very reasonable. I'll work on that.

rcrowley avatar Oct 05 '14 00:10 rcrowley

Discussed recently with a friend how much of a difference it would be if the Mutexes were replaced with channels for the same thread safety. This would also get rid of the defer I'll put some benchmarks together and an eventual PR if it proves to be better

lmineiro avatar Nov 16 '15 19:11 lmineiro