thriftrw / thriftrw-go

A Thrift encoding code generator and library for Go
MIT License
101 stars 53 forks source link

optimise ReadIntXxx() funcs #572

Closed saurabhagrawal-86 closed 1 year ago

saurabhagrawal-86 commented 1 year ago

Using io.ByteReader to decode integers

benchstat results:

name         old time/op  new time/op  delta
ReadInt8     10.7ns ±28%   5.2ns ± 2%  -51.11%  (p=0.008 n=5+5)
ReadInt8-2   10.0ns ± 8%   5.2ns ± 2%  -48.22%  (p=0.008 n=5+5)
ReadInt8-4   9.87ns ± 5%  5.18ns ± 1%  -47.50%  (p=0.008 n=5+5)
ReadInt16    14.3ns ± 3%   7.2ns ± 5%  -49.49%  (p=0.008 n=5+5)
ReadInt16-2  14.0ns ± 3%   7.0ns ± 2%  -49.93%  (p=0.008 n=5+5)
ReadInt16-4  14.9ns ± 4%   7.2ns ± 3%  -51.98%  (p=0.008 n=5+5)
ReadInt32    19.5ns ± 3%  11.3ns ± 1%  -42.35%  (p=0.008 n=5+5)
ReadInt32-2  19.8ns ± 5%  11.3ns ± 3%  -43.11%  (p=0.008 n=5+5)
ReadInt32-4  20.3ns ± 5%  11.3ns ± 4%  -44.18%  (p=0.008 n=5+5)
ReadInt64    32.0ns ± 2%  18.6ns ± 2%  -41.76%  (p=0.008 n=5+5)
ReadInt64-2  32.4ns ±10%  18.4ns ± 2%  -43.27%  (p=0.008 n=5+5)
ReadInt64-4  34.9ns ± 6%  18.6ns ± 4%  -46.65%  (p=0.008 n=5+5)
CLAassistant commented 1 year ago

CLA assistant check
All committers have signed the CLA.

saurabhagrawal-86 commented 1 year ago

I will remove the non-Go files before merging.