Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reduce number of useless color codes written to stdout (average 21.5%)
This reduces output size in our tests as follows: ``` ./testdata/syntect/ansi16_colors.out 923 -> 918 (0.544% smaller) ./testdata/syntect/ansi256_colors.out 1232 -> 1122 (9.803% smaller) ./testdata/syntect/background.out 1959 -> 1564 (25.25% smaller) ./testdata/syntect/default.out 1451 -> 1264 (14.79% smaller) ./testdata/syntect/emoji.out 1495 -> 1289 (15.98% smaller) ./testdata/syntect/emoji_bg.out 2273 -> 1777 (27.91% smaller) ./testdata/syntect/empty_lines.out 1705 -> 1518 (12.31% smaller) ./testdata/syntect/empty_lines_bg.out 2904 -> 2269 (27.98% smaller) ./testdata/syntect/first_only.out 2837 -> 2235 (26.93% smaller) ./testdata/syntect/hard_tab.out 2088 -> 1597 (30.74% smaller) ./testdata/syntect/japanese_background.out 2237 -> 1741 (28.48% smaller) ./testdata/syntect/japanese_default.out 1612 -> 1388 (16.13% smaller) ./testdata/syntect/long_line.out 2338 -> 2096 (11.54% smaller) ./testdata/syntect/long_line_bg.out 3172 -> 2578 (23.04% smaller) ./testdata/syntect/multi_chunks_bg.out 7824 -> 5171 (51.30% smaller) ./testdata/syntect/multi_chunks_default.out 4366 -> 3425 (27.47% smaller) ./testdata/syntect/multi_chunks_no_grid.out 3701 -> 2703 (36.92% smaller) ./testdata/syntect/multi_line_numbers.out 3338 -> 2815 (18.57% smaller) ./testdata/syntect/no_grid.out 894 -> 688 (29.94% smaller) ./testdata/syntect/no_grid_background.out 1374 -> 960 (43.12% smaller) ./testdata/syntect/no_wrap_background.out 2500 -> 1890 (32.27% smaller) ./testdata/syntect/no_wrap_default.out 1920 -> 1582 (21.36% smaller) ./testdata/syntect/no_wrap_no_grid.out 1357 -> 1000 (35.69% smaller) ./testdata/syntect/region_at_end_of_line.out 1665 -> 1420 (17.25% smaller) ./testdata/syntect/region_at_end_of_line_bg.out 2239 -> 1722 (30.02% smaller) ./testdata/syntect/region_at_line_start.out 1581 -> 1375 (14.98% smaller) ./testdata/syntect/tab_width_2.out 2098 -> 1607 (30.55% smaller) ./testdata/syntect/theme.out 1453 -> 1304 (11.42% smaller) ./testdata/syntect/whole_line.out 1286 -> 1191 (7.976% smaller) ./testdata/syntect/wide_char_region.out 1465 -> 1278 (14.63% smaller) ./testdata/syntect/wide_char_region_bg.out 1964 -> 1569 (25.17% smaller) ./testdata/syntect/wrap_3_lines_emoji.out 2253 -> 2029 (11.03% smaller) ./testdata/syntect/wrap_ansi256.out 1646 -> 1448 (13.67% smaller) ./testdata/syntect/wrap_between_bg.out 2641 -> 2031 (30.03% smaller) ./testdata/syntect/wrap_between_text.out 2047 -> 1709 (19.77% smaller) ./testdata/syntect/wrap_break_wide_char.out 2252 -> 1876 (20.04% smaller) ./testdata/syntect/wrap_break_wide_char_bg.out 3081 -> 2257 (36.50% smaller) ./testdata/syntect/wrap_emoji.out 2044 -> 1706 (19.81% smaller) ./testdata/syntect/wrap_emoji_zwj.out 2067 -> 1729 (19.54% smaller) ./testdata/syntect/wrap_japanese_after.out 2536 -> 2065 (22.80% smaller) ./testdata/syntect/wrap_japanese_before.out 2537 -> 2066 (22.79% smaller) ./testdata/syntect/wrap_japanese_louise.out 5738 -> 5532 (3.723% smaller) ./testdata/syntect/wrap_jp_louise_bg.out 6617 -> 6203 (6.674% smaller) ./testdata/syntect/wrap_jp_louise_no_grid.out 4996 -> 4771 (4.715% smaller) ./testdata/syntect/wrap_match_at_second_line.out 2207 -> 1793 (23.08% smaller) ./testdata/syntect/wrap_match_at_second_line_bg.out 2793 -> 2107 (32.55% smaller) ./testdata/syntect/wrap_middle_of_spaces.out 2051 -> 1713 (19.73% smaller) ./testdata/syntect/wrap_middle_of_tab.out 2029 -> 1691 (19.98% smaller) ./testdata/syntect/wrap_middle_of_text.out 2049 -> 1711 (19.75% smaller) ./testdata/syntect/wrap_middle_text_bg.out 2641 -> 2031 (30.03% smaller) ./testdata/syntect/wrap_no_grid.out 1481 -> 1124 (31.76% smaller) ./testdata/syntect/wrap_region_accross_line.out 2219 -> 1805 (22.93% smaller) ./testdata/syntect/wrap_region_jp_accross_line.out 2225 -> 1811 (22.86% smaller) ./testdata/syntect/wrap_region_line_end.out 1838 -> 1577 (16.55% smaller) ./testdata/syntect/wrap_region_line_start.out 1820 -> 1575 (15.55% smaller) ./testdata/syntect/wrap_theme.out 2045 -> 1783 (14.69% smaller) ./testdata/syntect/wrap_twice.out 2656 -> 2186 (21.50% smaller) ./testdata/syntect/wrap_whole_3_lines.out 1763 -> 1650 (6.848% smaller) ``` CPU performance does not change. Benchmark: ``` group after before ----- ----- ------ syntect::package-lock.json 1.01 722.0±36.85ms ? ?/sec 1.00 711.9±33.71ms ? ?/sec syntect::ripgrep-large 1.01 430.9±8.01ms ? ?/sec 1.00 428.4±7.48ms ? ?/sec syntect::ripgrep-small 1.01 110.5±1.35ms ? ?/sec 1.00 109.7±1.14ms ? ?/sec syntect::ripgrep-tiny 1.00 49.5±0.38ms ? ?/sec 1.00 49.4±0.30ms ? ?/sec ``` Command: ``` > hyperfine './before -p syntect Arg ../../clap-rs/clap/src' './after -p syntect Arg ../../clap-rs/clap/src' Benchmark #1: ./before -p syntect Arg ../../clap-rs/clap/src Time (mean ± σ): 292.3 ms ± 3.7 ms [User: 1.192 s, System: 0.040 s] Range (min … max): 285.2 ms … 299.8 ms 10 runs Benchmark #2: ./after -p syntect Arg ../../clap-rs/clap/src Time (mean ± σ): 290.9 ms ± 3.2 ms [User: 1.180 s, System: 0.041 s] Range (min … max): 285.1 ms … 294.6 ms 10 runs Summary './after -p syntect Arg ../../clap-rs/clap/src' ran 1.00 ± 0.02 times faster than './before -p syntect Arg ../../clap-rs/clap/src' ``` but writing the output to terminal seems improved by around 6~10%
- Loading branch information