std/lzw: add "#truncated input" error

name                                         old speed      new speed      delta

wuffs_gif_decode_1k_bw/clang11                659MB/s ± 0%   748MB/s ± 0%  +13.43%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_full_init/clang11   182MB/s ± 0%   178MB/s ± 0%   -2.17%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_part_init/clang11   223MB/s ± 0%   219MB/s ± 0%   -2.00%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_bgra/clang11             799MB/s ± 0%   795MB/s ± 0%   -0.52%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_indexed/clang11          211MB/s ± 0%   210MB/s ± 0%   -0.47%  (p=0.008 n=5+5)
wuffs_gif_decode_20k/clang11                  250MB/s ± 1%   254MB/s ± 0%   +1.75%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/clang11      581MB/s ± 0%   568MB/s ± 0%   -2.09%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_realistic/clang11       221MB/s ± 0%   221MB/s ± 0%     ~     (p=0.690 n=5+5)
wuffs_gif_decode_1000k_full_init/clang11      222MB/s ± 0%   224MB/s ± 0%   +0.65%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k_part_init/clang11      223MB/s ± 0%   224MB/s ± 0%   +0.58%  (p=0.008 n=5+5)
wuffs_gif_decode_anim_screencap/clang11      1.28GB/s ± 0%  1.30GB/s ± 0%   +1.45%  (p=0.008 n=5+5)

wuffs_gif_decode_1k_bw/gcc10                  595MB/s ± 0%   642MB/s ± 0%   +7.91%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_full_init/gcc10     168MB/s ± 0%   169MB/s ± 0%   +0.36%  (p=0.008 n=5+5)
wuffs_gif_decode_1k_color_part_init/gcc10     202MB/s ± 0%   203MB/s ± 0%   +0.46%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_bgra/gcc10               790MB/s ± 0%   798MB/s ± 0%   +1.04%  (p=0.008 n=5+5)
wuffs_gif_decode_10k_indexed/gcc10            208MB/s ± 0%   210MB/s ± 0%   +1.00%  (p=0.008 n=5+5)
wuffs_gif_decode_20k/gcc10                    258MB/s ± 0%   266MB/s ± 0%   +3.08%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_artificial/gcc10        566MB/s ± 0%   577MB/s ± 0%   +1.83%  (p=0.008 n=5+5)
wuffs_gif_decode_100k_realistic/gcc10         220MB/s ± 0%   227MB/s ± 0%   +3.03%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k_full_init/gcc10        223MB/s ± 0%   231MB/s ± 0%   +3.23%  (p=0.008 n=5+5)
wuffs_gif_decode_1000k_part_init/gcc10        224MB/s ± 0%   231MB/s ± 0%   +3.14%  (p=0.008 n=5+5)
wuffs_gif_decode_anim_screencap/gcc10        1.30GB/s ± 0%  1.32GB/s ± 0%   +1.70%  (p=0.008 n=5+5)

wuffs_lzw_decode_20k/clang11                  294MB/s ± 0%   321MB/s ± 0%   +9.11%  (p=0.008 n=5+5)
wuffs_lzw_decode_100k/clang11                 533MB/s ± 0%   560MB/s ± 0%   +5.13%  (p=0.008 n=5+5)

wuffs_lzw_decode_20k/gcc10                    271MB/s ± 0%   272MB/s ± 0%   +0.55%  (p=0.008 n=5+5)
wuffs_lzw_decode_100k/gcc10                   527MB/s ± 0%   521MB/s ± 0%   -1.31%  (p=0.008 n=5+5)

Updates #96
This commit is contained in:
Nigel Tao committed 2023-01-31 20:18:53 +11:00
1 parent 5640296546
commit 48e69da5af
4 files changed
+71 -10

No files matched your search

+16 -5
View File
@@ -13,6 +13,7 @@
// limitations under the License.
pub status "#bad code"
pub status "#truncated input"
pri status "#internal error: inconsistent I/O"
@@ -119,6 +120,8 @@ pub func decoder.transform_io?(dst: base.io_writer, src: base.io_reader, workbuf
} else if this.read_from_return_value == 2 {
yield? base."$short read"
} else if this.read_from_return_value == 3 {
return "#truncated input"
} else if this.read_from_return_value == 4 {
return "#bad code"
} else {
return "#internal error: inconsistent I/O"
@@ -167,7 +170,11 @@ pri func decoder.read_from!(src: base.io_reader) {
assert width <= n_bits via "a <= b: a <= c; c <= b"(c: 12)
assert n_bits >= width via "a >= b: b <= a"()
} else if args.src.length() <= 0 {
this.read_from_return_value = 2
if args.src.is_closed() {
this.read_from_return_value = 3
} else {
this.read_from_return_value = 2
}
break
} else {
bits |= args.src.peek_u8_as_u32() << n_bits
@@ -176,7 +183,11 @@ pri func decoder.read_from!(src: base.io_reader) {
if n_bits >= width {
// No-op.
} else if args.src.length() <= 0 {
this.read_from_return_value = 2
if args.src.is_closed() {
this.read_from_return_value = 3
} else {
this.read_from_return_value = 2
}
break
} else {
bits |= args.src.peek_u8_as_u32() << n_bits
@@ -188,7 +199,7 @@ pri func decoder.read_from!(src: base.io_reader) {
// This if condition is always false, but for some unknown
// reason, removing it worsens the benchmarks slightly.
if n_bits < width {
this.read_from_return_value = 4
this.read_from_return_value = 5
break
}
}
@@ -297,7 +308,7 @@ pri func decoder.read_from!(src: base.io_reader) {
}
} else {
this.read_from_return_value = 3
this.read_from_return_value = 4
break
}
@@ -319,7 +330,7 @@ pri func decoder.read_from!(src: base.io_reader) {
if args.src.can_undo_byte() {
args.src.undo_byte!()
} else {
this.read_from_return_value = 4
this.read_from_return_value = 5
break
}
} endwhile