📄 mail-2001-01-23
字号:
Delivered-To: urba-cgu@urbanet.ch From: James House <james.house@medibuy.com> To: Ceki Gulcu <cgu@urbanet.ch> Subject: RE: Buffering issues Date: Tue, 23 Jan 2001 11:38:30 -0800 X-Mailer: Internet Mail Service (5.5.2650.21) Ceki,Most of the "speed" issues can be easily solved, as demonstrated inthe new versions of the files that are attached, and as describedhere:The "drawing" of the panel is time consuming. And let's face it: wewill never build a swing component that can re-draw itself thousandsof times per second - nor could the human eye keep up with that anyway(60-ish redraws per second is the limit of what most humans canperceive).I think you'll agree that regardless of which choice of swingcomponents, the issue of not being able to draw more than 100 timesper second (if that) will be a constant.Possible solutions to wasting a lot of time redrawing are: * Redraw every N messages * Redraw every N milliseconds * Redraw when a message of a high priority is received * Only redraw if the changes (new messages) are visible (depending onscroll-bar position)I made some very small changes (which are some of what I outlined inthe previous e-mail as things on the to-do list), and you should beable to see a great difference in performance.In general the changes are: Use a "queue" to asynchronously deliverthe messages to the panel for updating, rather than having the callingthread (the one generating the log message) be responsible forre-drawing the panel - this frees up the thread to continue on withoutwaiting for the logging mechanism. The "queue" has a thread thatwakes up every N milliseconds, or when a message of a specifiedpriority arrives. It then delivers all queued messages to the panel,which then redraws ONCE for the entire batch of queued messages IF thenew messages are visible in the display.With the "tail" mechanism turned on (so that any new set of messagesforces a redraw, because the last message is always visible), thepanel can now log about a thousand messages in 1 second. With tailturned off (so that redraw is only required if the panel is showingthe space the new messages will be printed), it can receive over a100,000 messages in just a few seconds. Also, most of the flicker isalready eliminated.Again, everything in the code is really "roughed in" - just there togive the general idea, not necessarily to do things in the best way -but I really feel that this kind of solution is what you'll have toend up with in the long term.James
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -