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: 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…


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…


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…


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; ……


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…


Source code for Windows Graphics Programming: Win32 GDI and DirectDraw

Source code for Windows Graphics Programming: Win32 GDI and DirectDraw used to be on http://safariexamples.informit.com/0130869856/. But link has been broken for quite sometimes. I’ve received a few emails from readers who has lost the CD of the book. If you need the source code, here is it: www.fengyuan.com/sample/Samples.zip

4

Anatomy of STL Vector: Data Size

In the last post, we discussed the cost of using STL vector to module size. Now let’s take a look at how STL vector manages its data. Dia2Dump (Source code available in Microsoft Visual Studio 8\Dia SDK\Samples\Dia2Dump directory) shows the following internal structure of vector<short:>     UDT       : std::vector<short,std::allocator<short> > BaseClass :   std::_Vector_val<short,std::allocator<short> >,…

1