stream-vbyte-go icon indicating copy to clipboard operation
stream-vbyte-go copied to clipboard

slice based look up

Open sreekanth-cb opened this issue 6 years ago • 0 comments

Map lookup in the decode path is having performance implications and a fix by replacing the map look up with a slice look up improves the performance like below.

For 10K numbers

BenchmarkTestSvbDecode-8       	   10000	    112119 ns/op	       0 B/op	       0 allocs/op

With slice look up,

var lookup = [][4]uint8{
	0x00: [4]uint8{1, 1, 1, 1},
	0x01: [4]uint8{1, 1, 1, 2},


BenchmarkTestSvbDecode-8       	   30000	     46381 ns/op	       0 B/op	       0 allocs/op

sreekanth-cb avatar Jul 02 '18 09:07 sreekanth-cb