yq
yq copied to clipboard
Very slow when printing with colors
Describe the bug yq is very slow when printing a YAML file with colors.
Version of yq: 4.24.2 Operating system: macOS Installed via: MacPorts
Input Yaml big.zip
Command
time yq -C big.yaml
Actual behavior Command takes more than half a minute to finish.
real 0m36.762s
user 1m31.913s
sys 0m2.216s
Expected behavior
Command completes in a couple seconds at most. For reference, time using the no colors flag -M:
real 0m0.382s
user 0m0.365s
sys 0m0.084s
looks like the runtime is at least quadatic with --colors
time yq -P -oy --no-colors ~/tmp/D20240430T175851_v4.yaml | wc -l 1091: 0.044 2191: 0.076 4157: 0.138
time yq -P -oy --colors ~/tmp/D20240430T175851_v4.yaml | wc -l 1091: 1.759 2191: 14.386 4157: 1:33.44
unfortunately, I couldn't use highlight (brew install highlight) as workaround:
cat ~/tmp/D20240430T175851_v4.yaml | /home/linuxbrew/.linuxbrew/opt/highlight/bin/highlight --out-format xterm256 --syntax yaml
produces bad formatting:
workaround1 : use moar
brew install moar
moar ~/tmp/D20240430T175851_v4.yaml cat ~/tmp/D20240430T175851_v4.yaml | moar --lang=yaml cat /pathto/foo.json | yq -P -oy | moar --lang=yaml
works correctly and fast
but see https://github.com/walles/moar/issues/207
workaround2 : use chroma
cat /pathto/foo.json | yq -P -oy | chroma --style=catppuccin-latte --lexer=yaml