简体   繁体   English

Delphi彩色文本组件替换了TRichEdit以提高性能

[英]Delphi lines colored Text component replacing TRichEdit to improve performances

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. 我目前在我的一个软件(在Delphi 7中)中将TRichEdit用作“实时”事件日志查看器,最近我对我的软件进行了介绍,而TRichEdit消耗了40%以上的软件CPU时间。

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.). 线着色(它可能是线语法颜色,因为不同的颜色线具有不同的前缀或HTML着色等)。
  • Easy Save to file function (to RTF or to HTML). 轻松保存到文件功能(RTF或HTML)。
  • Free or Open source. 免费或开源。
  • Good perf. 好表现 even for 'large files' (may be 200 Mo) as viewer. 甚至对于“大文件”(可能是200 Mo)作为查看器。

Info : I yet look at this post but without good answer for me. 信息:我仍在看这篇文章,但对我来说却没有好的答案。

Check out TConsole / TColorConsole circa 1996: http://www.torry.net/authorsmore.php?id=604 大约在1996年查看TConsole / TColorConsole: 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. 它不执行HTML,不执行RTF,但确实可以快速滚动彩色文本。 ;> ;>

For 'real time' event log viewer I'd recommend using VirtualTreeView . 对于“实时”事件日志查看器,我建议使用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. 它能够处理几乎不受限制的行数,具有大量的自定义功能(如自定义着色和自定义绘图中的所有内容),支持unicode,并且即使列表中已有几百万个项目,其运行速度也非常快。 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 . 我提到的唯一可以满足您大部分(如果不是全部)需求的组件-TRichView I've tried TSynEdit and I can say that it has a lot of features but seriously lacks performance. 我尝试过TSynEdit ,可以说它具有很多功能,但严重缺乏性能。

Try VirtualTreeView and you won't regret it. 尝试VirtualTreeView,您将不会后悔。

Maybe you can log to a clientdataset. 也许您可以登录到clientdataset。 The DBGrid allows you to specify all kinds of drawing options, so you can specify a background color based on the visible lines. DBGrid允许您指定各种绘图选项,因此您可以基于可见线指定背景色。 The ClientDataset can easily manage quite a lot of data, and the grid will only draw those rows that are visible. ClientDataset可以轻松管理大量数据,并且网格只会绘制那些可见的行。

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. 也许您应该通过将行缓存在临时日志中,并每隔几秒钟将它们批量添加到可见日志中来减少实时性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM