Commit 8a8c5dd
committed
optimize varint encoded len calculation
Based on the cpp Protobuf implementation. This is a big win: encoded_len_varint
is now constant time WRT the input integer size.
name control ns/iter variable ns/iter diff ns/iter diff % speedup
encoded_len_varint_small 111 (7207 MB/s) 110 (7272 MB/s) -1 -0.90% x 1.01
encoded_len_varint_medium 361 (2216 MB/s) 110 (7272 MB/s) -251 -69.53% x 3.28
encoded_len_varint_mixed 420 (1904 MB/s) 111 (7207 MB/s) -309 -73.57% x 3.78
encoded_len_varint_large 464 (1724 MB/s) 110 (7272 MB/s) -354 -76.29% x 4.221 parent 47d4c0f commit 8a8c5dd
1 file changed
Lines changed: 3 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
150 | | - | |
151 | | - | |
152 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
153 | 146 | | |
154 | 147 | | |
155 | 148 | | |
| |||
0 commit comments