Is there a more efficient text spooler than TextWriter/StringBuilder

For a situation like capturing text incrementally, for example if you were receiving all of the output.write calls when a page was rendering, and those were being appended into a textwriter over a stringbuilder.

Is there a more efficient way to do this? Something that exists in dotnet already preferably? Especially if there's a total size over a hundred k. Maybe something more like an array of pages rather than contiguous memory?

Answers


I think StringBuilder is the most efficient way to append text in .net. To be more efficient you can specify the initial size of the StringBuilder when you create it.


It depends on what you're doing with that text.

If the concern is tracing or logging, I'd say your best bet is to use ETW (Event Tracing for Windows). It's a kernel-level tracing facility that's been built into Windows since Windows 2000 and it's much, much faster than doing file I/O.

If you're not using .NET 2.0, you have to do a little win32 API work to use it, and you have to create a provider class that you register on the system. It's a little complicated but worth the effort.

If you're using .NET 3.5, the managed Etw classes can be found in System.Diagnostics.Eventing.


That's as good as it gets. You can use a StringWriter but it's still writing into a StringBuilder


Need Your Help

Abort insert ... select clause

java sql oracle hibernate

Is it possible to abort an insert ... select clause from Java ? Using either JDBC or Hibernate, it doesn't matter. The DB is Oracle.

display all tables that start with specific characters

unix informix

I want to show or search all the tables in the database that start with the name 'bar'. Is that something I can do through the command line?