[Mono-bugs] [Bug 61167][Nor] New - Extremely slow String.Replace method
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Mon, 5 Jul 2004 07:30:15 -0400 (EDT)
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 david.gillemo@tv4.se.
http://bugzilla.ximian.com/show_bug.cgi?id=61167
--- shadow/61167 2004-07-05 07:30:15.000000000 -0400
+++ shadow/61167.tmp.28119 2004-07-05 07:30:15.000000000 -0400
@@ -0,0 +1,141 @@
+Bug#: 61167
+Product: Mono: Runtime
+Version: unspecified
+OS:
+OS Details: Win2k Pro
+Status: NEW
+Resolution:
+Severity: Unknown
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: david.gillemo@tv4.se
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: Extremely slow String.Replace method
+
+Description of Problem:
+Extremely slow String.Replace method. Possibly memory leak (?).
+
+
+Steps to reproduce the problem:
+1. Compile and run the attached code with "mono Console.exe"
+2.
+3.
+
+
+Actual Results:
+-Mono 1.0 (release 30 june) output-
+
+Starting replace 2004-07-05 12:09:33
+Replace 1: 2004-07-05 12:09:33
+Replace 2: 2004-07-05 12:09:33
+Replace 3: 2004-07-05 12:09:33
+Replace 4: 2004-07-05 12:09:33
+Replace 5: 2004-07-05 12:09:35
+Replace 6: 2004-07-05 12:09:40
+Replace 7: 2004-07-05 12:10:04
+Replace 8: 2004-07-05 12:11:49
+Replace 9: 2004-07-05 12:15:23
+Replace 10: 2004-07-05 12:18:56
+Replace 11: 2004-07-05 12:22:24
+Replace 12: 2004-07-05 12:25:50
+Replace 13: 2004-07-05 12:29:19
+Replace 14: 2004-07-05 12:32:46
+Replace 15: 2004-07-05 12:36:13
+Replace 16: 2004-07-05 12:39:41
+... (at timestamp 13:22 I couldn't wait any longer, so I stopped the
+process)
+
+
+Expected Results:
+-Microsoft .NET (1.1) output-
+
+Starting replace 2004-07-05 12:09:27
+Replace 1: 2004-07-05 12:09:27
+Replace 2: 2004-07-05 12:09:27
+Replace 3: 2004-07-05 12:09:27
+Replace 4: 2004-07-05 12:09:27
+Replace 5: 2004-07-05 12:09:27
+Replace 6: 2004-07-05 12:09:27
+Replace 7: 2004-07-05 12:09:28
+Replace 8: 2004-07-05 12:09:28
+Replace 9: 2004-07-05 12:09:28
+Replace 10: 2004-07-05 12:09:28
+Replace 11: 2004-07-05 12:09:28
+Replace 12: 2004-07-05 12:09:28
+Replace 13: 2004-07-05 12:09:28
+Replace 14: 2004-07-05 12:09:28
+Replace 15: 2004-07-05 12:09:28
+Replace 16: 2004-07-05 12:09:28
+Replace 17: 2004-07-05 12:09:28
+Replace 18: 2004-07-05 12:09:28
+Replace 19: 2004-07-05 12:09:28
+
+
+How often does this happen?
+Every time.
+
+
+Additional Information:
+The mono.exe process runs at 100% constantly during execution. The code
+runs flawless in Microsoft .NET. The code should in no way take up to an
+hour or more to execute.
+
+
+The code I'm running to test this (could look better/smaller but it
+displays my problem):
+
+string MyString = "This is a string to test the replace function. The
+characters åäö in swedish should be replaced width {}[";
+
+// Adding string to get some length...
+MyString += MyString;
+MyString += MyString;
+MyString += MyString;
+MyString += MyString;
+
+Console.WriteLine("Starting replace " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x00\x01", "\x01");
+Console.WriteLine("Replace 1: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x01\x01", "\x01");
+Console.WriteLine("Replace 2: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x02\x01", "\x01");
+Console.WriteLine("Replace 3: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x03\x01", "\x01");
+Console.WriteLine("Replace 4: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x04\x01", "\x01");
+Console.WriteLine("Replace 5: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x05\x01", "\x01");
+Console.WriteLine("Replace 6: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x06\x01", "\x01");
+Console.WriteLine("Replace 7: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x07\x01", "\x01");
+Console.WriteLine("Replace 8: " + DateTime.Now.ToString());
+
+MyString = MyString.Replace("\x00\x00", "\x00");
+Console.WriteLine("Replace 9: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x01\x00", "\x00");
+Console.WriteLine("Replace 10: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x02\x00", "\x00");
+Console.WriteLine("Replace 11: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x03\x00", "\x00");
+Console.WriteLine("Replace 12: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x04\x00", "\x00");
+Console.WriteLine("Replace 13: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x05\x00", "\x00");
+Console.WriteLine("Replace 14: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x06\x00", "\x00");
+Console.WriteLine("Replace 15: " + DateTime.Now.ToString());
+MyString = MyString.Replace("\x07\x00", "\x00");
+Console.WriteLine("Replace 16: " + DateTime.Now.ToString());
+
+// Swedish special characters.
+MyString = MyString.Replace("å", "{");
+Console.WriteLine("Replace 17: " + DateTime.Now.ToString());
+MyString = MyString.Replace("ä", "}");
+Console.WriteLine("Replace 18: " + DateTime.Now.ToString());
+MyString = MyString.Replace("ö", "[");
+Console.WriteLine("Replace 19: " + DateTime.Now.ToString());