mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 16:47:28 +01:00
Fill the LZW bit buffer less often
name old speed new speed delta wuffs_gif_decode_1k_bw/clang 292MB/s ± 1% 256MB/s ± 1% -12.29% (p=0.008 n=5+5) wuffs_gif_decode_1k_color/clang 143MB/s ± 0% 159MB/s ± 0% +10.95% (p=0.008 n=5+5) wuffs_gif_decode_10k/clang 150MB/s ± 1% 165MB/s ± 0% +10.24% (p=0.008 n=5+5) wuffs_gif_decode_100k/clang 152MB/s ± 0% 150MB/s ± 0% -1.19% (p=0.016 n=4+5) wuffs_gif_decode_1000k/clang 156MB/s ± 1% 153MB/s ± 1% -1.60% (p=0.008 n=5+5) wuffs_gif_decode_1k_bw/gcc 250MB/s ± 1% 330MB/s ± 0% +31.99% (p=0.008 n=5+5) wuffs_gif_decode_1k_color/gcc 172MB/s ± 1% 184MB/s ± 1% +7.40% (p=0.008 n=5+5) wuffs_gif_decode_10k/gcc 189MB/s ± 0% 193MB/s ± 0% +2.31% (p=0.008 n=5+5) wuffs_gif_decode_100k/gcc 166MB/s ± 0% 180MB/s ± 0% +8.56% (p=0.008 n=5+5) wuffs_gif_decode_1000k/gcc 171MB/s ± 0% 186MB/s ± 0% +8.19% (p=0.008 n=5+5) wuffs_lzw_decode_20k/clang 168MB/s ± 3% 168MB/s ± 0% ~ (p=0.222 n=5+5) wuffs_lzw_decode_100k/clang 252MB/s ± 1% 239MB/s ± 0% -4.89% (p=0.008 n=5+5) wuffs_lzw_decode_20k/gcc 209MB/s ± 0% 217MB/s ± 0% +4.28% (p=0.008 n=5+5) wuffs_lzw_decode_100k/gcc 307MB/s ± 0% 314MB/s ± 0% +2.27% (p=0.008 n=5+5)
This commit is contained in:
1 parent
24e7ee0104
commit
6945bdc75c
2 files changed
+62
-48
No files matched your search
+30
-23
@@ -63,33 +63,40 @@ pub func decoder.decode!??(dst base.io_writer, src base.io_reader) {
|
||||
var n_bits base.u32[..31]
|
||||
|
||||
while true {
|
||||
if args.src.available() >= 4 {
|
||||
// Read 4 bytes, using the "Variant 4" technique of
|
||||
// https://fgiesen.wordpress.com/2018/02/20/reading-bits-in-far-too-many-ways-part-2/
|
||||
bits |= (args.src.peek_u32le() as base.u32) ~mod<< n_bits
|
||||
args.src.skip_fast!(actual:(31 - n_bits) >> 3, worst_case:3)
|
||||
n_bits |= 24
|
||||
assert width <= n_bits via "a <= b: a <= c; c <= b"(c:12)
|
||||
assert n_bits >= width via "a >= b: b <= a"()
|
||||
} else {
|
||||
while n_bits < width,
|
||||
post n_bits >= width,
|
||||
{
|
||||
if n_bits < width {
|
||||
if args.src.available() >= 4 {
|
||||
// Read 4 bytes, using the "Variant 4" technique of
|
||||
// https://fgiesen.wordpress.com/2018/02/20/reading-bits-in-far-too-many-ways-part-2/
|
||||
bits |= (args.src.peek_u32le() as base.u32) ~mod<< n_bits
|
||||
args.src.skip_fast!(actual:(31 - n_bits) >> 3, worst_case:3)
|
||||
n_bits |= 24
|
||||
assert width <= n_bits via "a <= b: a <= c; c <= b"(c:12)
|
||||
assert n_bits >= width via "a >= b: b <= a"()
|
||||
} else {
|
||||
assert n_bits < 12 via "a < b: a < c; c <= b"(c:width)
|
||||
while args.src.available() <= 0,
|
||||
inv n_bits < 12,
|
||||
post args.src.available() >= 1,
|
||||
while true,
|
||||
pre n_bits < 12,
|
||||
post n_bits >= width,
|
||||
{
|
||||
if j > 0 {
|
||||
this.flush_j = j
|
||||
this.flush!??(dst:args.dst)
|
||||
j = 0
|
||||
while args.src.available() <= 0,
|
||||
inv n_bits < 12,
|
||||
post args.src.available() >= 1,
|
||||
{
|
||||
if j > 0 {
|
||||
this.flush_j = j
|
||||
this.flush!??(dst:args.dst)
|
||||
j = 0
|
||||
}
|
||||
yield status "$short read"
|
||||
}
|
||||
yield status "$short read"
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
if n_bits >= width {
|
||||
break
|
||||
}
|
||||
assert n_bits < 12 via "a < b: a < c; c <= b"(c:width)
|
||||
}
|
||||
bits |= (args.src.peek_u8() as base.u32) << n_bits
|
||||
args.src.skip_fast!(actual:1, worst_case:1)
|
||||
n_bits += 8
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user