[Mono-bugs] [Bug 77792][Nor] Changed - Poor performace of Int32.ToString () and other primitive types

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Sun Apr 2 23:21:35 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by kazuki at panicode.com.

http://bugzilla.ximian.com/show_bug.cgi?id=77792

--- shadow/77792	2006-04-02 23:17:38.000000000 -0400
+++ shadow/77792.tmp.17122	2006-04-02 23:21:35.000000000 -0400
@@ -136,6 +136,58 @@
 Hmm, kazuki's patch seems to cause several NUnit regressions..
 
 ------- Additional Comments From kazuki at panicode.com  2006-04-02 23:17 -------
 Created an attachment (id=16723)
 fix
 
+
+------- Additional Comments From kazuki at panicode.com  2006-04-02 23:21 -------
+I measured the performance of NumberFormatter and IntegerFormatter,
+using latest mono (rev.58893).
+
+the code used to measure the perfomance:
+static void Main () {
+   string[] formats = new string[]{"c", "d", "f", "g", "e", "x"};
+   int N = 1000000;
+   for (int i = 0; i < formats.Length; i++) {
+      DateTime dt = DateTime.Now;
+      for (int q = 0; q < N; q++)
+         q.ToString (formats[i]);
+      Console.WriteLine ("{0}: {1}ms", formats[i],
+DateTime.Now.Subtract (dt).TotalMilliseconds);
+   }
+}
+
+IntegerFormatter before refactoring (rev. 38559)
+  c: 2297ms
+  d: 1313ms
+  f: 1343ms
+  g: 1329ms
+  e: 1843ms
+  x: 797ms
+  Total memory allocated: 663240 KB
+
+NumberFormatter after refactoring
+  c: 1610ms
+  d: 969ms
+  f: 1110ms
+  g: 1296ms
+  e: 1344ms
+  x: 1531ms
+  Total memory allocated: 633026 KB
+
+NumberFormatter after refactoring + hex formatting patch
+  c: 1609ms
+  d: 984ms
+  f: 1110ms
+  g: 1312ms
+  e: 1344ms
+  x: 391ms
+  Total memory allocated: 564775 KB
+
+NumberFormatter was definitely slower than IntegerFormatter last time
+I posted on ML, but with the current version of Mono NumberFormatter
+is faster. I don't know why this inversion happened though.
+
+I guess revising the hexadecimal conversion part is enough to solve
+the situation. what's your thought?
+


More information about the mono-bugs mailing list