3

I currently use TRichEdit as an 'real time' event log viewer in one of my software (in Delphi 7) and I recently profile my software and TRichEdit is consuming more than 40% of the software cpu time.

I just want to test other components in order to compare performances, this component must have :

  • Line Coloring (it may be LINE syntax color, since different colors lines have different prefixes Or HTML coloring etc.).
  • Easy Save to file function (to RTF or to HTML).
  • Free or Open source.
  • Good perf. even for 'large files' (may be 200 Mo) as viewer.

Info : I yet look at this post but without good answer for me.

Community
  • 1
  • 1
philnext
  • 3,242
  • 5
  • 39
  • 62
  • So, what was wrong with the [SynMemoEx component](http://synopse.info/fossil/finfo?name=SynMemoEx.pas) ? – LU RD Nov 15 '11 at 22:12
  • 1
    @LURD I really like the Synopse components, but here, I have had some problems to 'extract' SynMemoEx from the site. – philnext Nov 16 '11 at 08:20

3 Answers3

3

Check out TConsole / TColorConsole circa 1996: http://www.torry.net/authorsmore.php?id=604

It doesn't do HTML, it doesn't do RTF, but it does do scrolling colored text pretty darned fast. ;>

dthorpe
  • 35,318
  • 5
  • 75
  • 119
  • Mmm... TConsole from...mmm Danny Thrope ? But in the source there is only TConsole no TconsoleColor. – philnext Nov 16 '11 at 08:29
  • No, it's from Danny Thorpe. :P TColorConsole is in the D2 release. Scroll down past the TConsole class. – dthorpe Nov 16 '11 at 17:35
  • OK Danny, I tried it : mini. 4x faster than TRichEdit. Good component indeed, deserve to be more known and exposed. I'll look for the rtf file save. – philnext Nov 16 '11 at 18:14
  • Thx. It was a fun/rewarding project back in the day. Glad to hear it still compiles and runs! – dthorpe Nov 16 '11 at 18:34
2

For 'real time' event log viewer I'd recommend using VirtualTreeView. It is capable of handling virtually unlimited number of rows, has tremendous amount of customization features (like custom coloring and custom drawing anything and everything), supports unicode and works extremely fast even with several million items already in the list. It does take some time to understand how everything works, but once you figure it out, you will never look back. It even supports in-place editing (including support for custom controls for every column). Every item is a record which can hold whatever data you need (not just the data you want to display). Incremental search is also supported, as well as extremely fast search from code, doesn't matter even if you have millions of items.

I'd avoid using any kind of 'standard' text editing components because of many restrictions imposed either by OS or by component itself. The only component I know of that can support most (if not all) of your requirements is already mentioned - TRichView. I've tried TSynEdit and I can say that it has a lot of features but seriously lacks performance.

Try VirtualTreeView and you won't regret it.

LightBulb
  • 964
  • 1
  • 11
  • 27
  • I always wanted to try VirtualTreeView I didn't know that it was able to be used as editor. I have TSynEdit (for other purposes) in the same project : to slow ! – philnext Nov 16 '11 at 08:14
  • Wait a minute. Now you want a control that can be used as an editor?! – David Heffernan Nov 16 '11 at 08:24
  • @DavidHeffernan Mmm..sorry, I just want a viewer. I would say that, for me, VirtualTreeView display TreeView, I did'nt know that it display 'Line colorised text'. – philnext Nov 16 '11 at 08:48
  • 1
    Why -1 here ? IMHO VirtualTreeView is a very good adept for this purpose. It has the capability for editing but you won't need this for event logging don't you ? – TLama Nov 16 '11 at 12:06
  • 1
    And the best thing about VirtualTreeView is the virtualization of data, i.e. data is best kept outside the component. – LU RD Nov 16 '11 at 12:23
1

Maybe you can log to a clientdataset. The DBGrid allows you to specify all kinds of drawing options, so you can specify a background color based on the visible lines. The ClientDataset can easily manage quite a lot of data, and the grid will only draw those rows that are visible.

Anyway, if you log a lot, constantly redrawing the logging component will slow down the application. Perhaps you should make the log less realtime by caching lines in a temporary log and add them in bulk to the visible log every few seconds.

GolezTrol
  • 114,394
  • 18
  • 182
  • 210
  • DBGrid ? Why not, but i'm not sure that the save to file is easy to do. I yet have some mechanisms to display the log in 'back time' and to display only the last lines, but for long and big streams it takes still a lot of time. – philnext Nov 16 '11 at 08:23
  • ClientDataset itself has got methods to save and load. It stores the data in an XML format, although I'm not sure how fast that will be, and of course maybe it's not the format you're hoping for. Anyway, you don't need to save the Grid, you save the dataset. If the log needs realtime saving too, I'd create a log method (class) that accepts a log string and pushes it to both the dataset and to a file. Saving log files can be fast if you add information to the end of the file. Don't try to rewrite the whole file on each save. – GolezTrol Nov 16 '11 at 09:06
  • If it really is that much data, it may be even better to log to a database and generate an HTML report on demand. You can make this page even poll (using AJAX) for new logs after the previous log. But all possible solutions aside, it's a good thing to think what exactly you need and why. Maybe you'll come up with a good solution yourself if you got your requirements straight. – GolezTrol Nov 16 '11 at 09:08