Jonas H. reported about slow horizontal scrolling on talk. http://rubyforge.org/pipermail/sup-talk/2010-December/004400.html I looked into it and found out that scrolling is pretty much fully dependant on Buffer#write and main cpu hogs within it are String#display_length (uses String#scan when on 1.8) and Ncurses::WINDOW#method_missing (wide/normal dispatching). Caching String#display_length cuts down String#scan calls by ~30%. That and hardwiring Ncurses::WINDOW#mvaddstr and #attrset cut average Buffer#write call to half of what it was. Also having configurable COL_JUMP would help people who need to scroll horizontally a lot. Included in the sup patch. Perceivable difference of these modifications is very small, at least to me. Please have a look if these patches (one of them against sup and another against ncursesw.rb in ncursesw gem) make any sense. ==== --- /usr/lib/ruby/gems/1.8/gems/ncursesw-1.2.4.2/lib/ncursesw.rb 2010-12- 31 00:37:31.000000000 +0200 +++ lib/ncurses.rb 2010-12-30 23:50:26.000000000 +0200 @@ -59,6 +58,29 @@ module Destroy_checker; def destroyed?; @destroyed; end; end class WINDOW include Destroy_checker + + @@mvwaddstr = Ncurses.respond_to? "mvwaddstr" + # This would be handled by #method_missing below, but for + # performance reasons it is extracted here. #mvaddstr is the beef + # of Redwood::Buffer#write which does all the drawing. + def mvaddstr(*args) + if @@mvwaddstr + Ncurses.mvwaddstr(*args) + else + Ncurses.mvaddstr(*args) + end + end + + @@wattrset = Ncurses.respond_to? "wattrset" + # See #mvaddstr abowe. + def attrset(*args) + if @@wattrset + Ncurses.wattrset(*args) + else + Ncurses.attrset(*args) + end + end + def method_missing(name, *args) name = name.to_s if (name[0,2] == "mv") ==== -- Tero Tilus ## 050 3635 235 ## http://tero.tilus.net/
Attachment:
0002-Performance-and-configurability-of-horizontal-scroll.patch
Description: Binary data
_______________________________________________ Sup-devel mailing list Sup-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/sup-devel