[Mono-devel-list] RE: [Mono-list] LANDED: managed
collation (CompareInfo) support
Atsushi Eno
atsushi at ximian.com
Mon Aug 8 05:04:42 EDT 2005
Hi Ilya,
> Great news! Thank you!
Thank you too, for all your help on it :-)
> Are you planning to make some performance banchmarks and compare results
> to
> "old" and may be MS.Net performance results?
Am not planning to measure comparison results between MS.NET and Mono,
but the attached example will show you the fact (to run it you will
have to create "sample.txt" where any content should be OK). It is
what I used to measure performance improvements on optimizing my code.
But it is good idea to measure comparison between ICU based code and
managed collation. I'll post a followup if I managed to get
icu-based code working (it is disabled now and am not sure if the
latest code works fine).
Atsushi Eno
-------------- next part --------------
using System;
using System.Globalization;
using System.IO;
using System.Text;
public class Test
{
public static void Main (string [] args)
{
string txt = new StreamReader ("sample.txt").ReadToEnd ();
for (int i = 0; i < 8; i++)
txt += txt;
Console.WriteLine ("string size is " + txt.Length);
StringBuilder sb = new StringBuilder ();
sb.Append (txt);
sb.Append ("A");
string txt2 = sb.ToString ();
CompareInfo ci = new CultureInfo ("en-US").CompareInfo;
GC.Collect (0); GC.Collect (1); GC.Collect (2);
Console.WriteLine (GC.GetTotalMemory (false));
//for (int i = 1; i < txt.Length; i++)
//if (ci.Compare (txt, 0, i, txt, 0, i) != 0)
// throw new Exception ("At " + i);
ci.Compare (txt, txt2, CompareOptions.IgnoreSymbols); // dummy
GC.Collect (0); GC.Collect (1); GC.Collect (2);
DateTime start = DateTime.Now;
// for (int i = 0; i < 20; i++)
if (ci.Compare (txt, txt2, CompareOptions.Ordinal) == 0)
throw new Exception (ci.Compare (txt, txt).ToString ());
Console.WriteLine ((DateTime.Now.Ticks - start.Ticks) + " / " + GC.GetTotalMemory (false));
GC.Collect (0); GC.Collect (1); GC.Collect (2);
start = DateTime.Now;
// for (int i = 0; i < 20; i++)
if (ci.Compare (txt, txt2, CompareOptions.None) == 0)
throw new Exception ();
Console.WriteLine ((DateTime.Now.Ticks - start.Ticks) + " / " + GC.GetTotalMemory (false));
GC.Collect (0); GC.Collect (1); GC.Collect (2);
start = DateTime.Now;
// for (int i = 0; i < 20; i++)
ci.Compare (txt, txt2, CompareOptions.StringSort);
Console.WriteLine ((DateTime.Now.Ticks - start.Ticks) + " / " + GC.GetTotalMemory (false));
GC.Collect (0); GC.Collect (1); GC.Collect (2);
start = DateTime.Now;
// for (int i = 0; i < 20; i++)
ci.Compare (txt, txt2, CompareOptions.IgnoreCase);
Console.WriteLine ((DateTime.Now.Ticks - start.Ticks) + " / " + GC.GetTotalMemory (false));
GC.Collect (0); GC.Collect (1); GC.Collect (2);
start = DateTime.Now;
// for (int i = 0; i < 20; i++)
ci.Compare (txt, txt2, CompareOptions.IgnoreSymbols);
Console.WriteLine ((DateTime.Now.Ticks - start.Ticks) + " / " + GC.GetTotalMemory (false));
GC.Collect (0); GC.Collect (1); GC.Collect (2);
start = DateTime.Now;
// for (int i = 0; i < 20; i++)
ci.Compare (txt, txt2, CompareOptions.IgnoreKanaType);
Console.WriteLine ((DateTime.Now.Ticks - start.Ticks) + " / " + GC.GetTotalMemory (false));
}
}
More information about the Mono-list
mailing list