Multiple colors makes redrawing very slow
I have an ncurses program which fills the screen with random text. It can be compiled in two modes: multi-color and single-color. In single-color mode, the redraw rate is very fast, but in multi-color mode, for some reason the redraw rate drops significantly. This is a problem in both the built-in OS X Terminal.app as well as iTerm.app. It's significantly better in iTerm than Terminal, but it looks like there's still something bottlenecking the color rendering.
I did some profiling, and found that in single-color mode, about 91.8% of the thread is devoted to the ncurses refresh() function, but in multi-color mode, the number jumps to 99.8%.
I suspect that the terminal is the root cause of this slowdown, since iTerm seems to have partially fixed the problem already when compared to the built-in Terminal.
In the attached reproducer program, the slowdown can be best seen when the terminal window takes up the entire screen. Binaries of each version of the program are included. To manually compile each version, toggle the "#define" on line 18 of main.c. (Note that some code is unused.)
- iTerm version: 2.1.4
- OS Version: 10.11.3 (15D21)
- Settings: com.googlecode.iterm2.plist
- Debug Log: debuglog.txt.zip
- Reproducer Program: iTerm_Demo.zip