XPS Again

I needed to generate images for an HTML document I’m generating, for which I use create a DrawingVisual and render it to a RenderTargetBitmap before saving to a PNG file. Now I would like to save the same visual to an XPS document. The benefit of having an XPS document is that you can zoom…

1

Performance Tips: Faster than StringBuilder?

The web has tons of articles about how StringBuilder is much faster than string concatenation using ‘+’ operator or String.Concat functions when there are enough strings to ber merged. Here is an MSDN article on this topic: http://support.microsoft.com/kb/306822 But actually, if all you want is concatenating strings, there is a more efficient way of doing…

7

Performance Tips: System.Text.StringBuilder and String.Concat

Much has been written about the benefits of using StringBuilder over string concatenation. So much so that there seems to be overuse of StringBuilder class, causing performance issues again. If you’re using StringBuilder and string concatenation a lot in your program, here are a few more things to ponder: String.Concat(str1, str2) is a perfect string…

2

Performance Tips: String.Split

String.Split methods are provided in .Net as a convenient way of dividing string into parts. Here are two basic forms of String.Split methods: public string[] Split(char[] separator, int count, StringSplitOptions options); public string[] Split(string[] separator, int count, StringSplitOptions options); Also String.Split methods are quite easy to use, there are hidde performance issues you should be…

0

TextWriter.WriteLine(string, object[]) in less memory, less time

I found myself increasingly generating reports in .csv format, and then use Excel to analyze the reports. With large amount of data written to the .csv file, file generation time becomes more and more noticable. So I took some time to check what is taking so much time and how can it be reduced. For…

1

Problem: Better way to remove characters that aren’t 32 to 175

There is a question on StackOverflow.com about better ways to remove characters in a string that are outside the range of 32 to 175. Quite a few fancy solutions are provided: Regex.Replace(myString, @”[^\x20-\xaf]+”, “”); new string(myString.Where(c => (c >= 32) && (c <= 175)).ToArray()); string text = (from c in myString let i = (int) c…

0

Drawing bearing and distance property line using C#/SVG/IE9/Visio (V2)

Here is expanded version of  my little C# program which converts property description in bearing and distance to SVG, which can then be viewed by IE9 or imported into Microsoft Visio: Program.cs (attached) New features: endpath command to end a path with stroking closepath command to end a path with stroking and filling p command to store…

0

Drawing bearing and distance property line using C#/SVG/IE9.

If you read an official property legal desciption, property line are often described using bearing and distance. Here is an example: BEGINGING AT THE NORTHWEST CORNER OF SAID SOUTHWEST QUARTER OF THE SOUTHWEST QUARTER OF SECTION 9; THENCE SOUTH 89°35’11” EAST; 246.35 FEET ALONG THE NORTH LINE THEREOF; THENCE SOUTH 19°38’26” EAST, 36.08 FEET; ……

0

EWD637: Three Golden Rules for Successful Scientific Research

Here is something I read in graduate school and still thinks about from time to time: Edsger W. Dijkstra’s Three Golden Rules for Successful Scientific Research: Raise your quality standards as high as you can live with, avoid wasting your time on routine problems, and always works as closely as possible at the boundary of your…

0

Optimization Note (C++) 1: push, pop, call _chkstk

I was looking at assembly code trying to improve an important performance scenario when I found a strange call to _chkstk 011E100E push 10h 011E1010 pop eax 011E1011 call _chkstk (011E1810h) 011E1016 mov ecx,esp My understanding is that _chkstk call is generatesd by C++ compiler when there are more than 4kb local variable allocation. But…

0