[Mono-bugs] [Bug 52395][Wis] New - System.Buffer.BlockCopy is slower than System.Array.Copy
bugzilla-daemon@bugzilla.ximian.com
bugzilla-daemon@bugzilla.ximian.com
Sat, 20 Dec 2003 00:50:24 -0500 (EST)
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 bmaurer@users.sf.net.
http://bugzilla.ximian.com/show_bug.cgi?id=52395
--- shadow/52395 2003-12-20 00:50:24.000000000 -0500
+++ shadow/52395.tmp.10071 2003-12-20 00:50:24.000000000 -0500
@@ -0,0 +1,69 @@
+Bug#: 52395
+Product: Mono/Runtime
+Version: unspecified
+OS:
+OS Details:
+Status: NEW
+Resolution:
+Severity:
+Priority: Wishlist
+Component: misc
+AssignedTo: mono-bugs@ximian.com
+ReportedBy: bmaurer@users.sf.net
+QAContact: mono-bugs@ximian.com
+TargetMilestone: ---
+URL:
+Cc:
+Summary: System.Buffer.BlockCopy is slower than System.Array.Copy
+
+Description of Problem:
+According to MSDN:
+"[The System.Buffer] class provides better performance for manipulating
+primitive types than similar methods in the Array class."
+
+However, on Mono, it is actually the other way around. This can have
+serious performance implications for trying to optimize code.
+
+Steps to reproduce the problem:
+class T {
+ const int sz = 128;
+ static void Main () {
+ byte [] src = new byte [sz];
+ byte [] dst = new byte [sz];
+
+ for (int i = 0; i < 10000000; i++) {
+#if BUFFER
+ System.Buffer.BlockCopy
+#else
+ System.Array.Copy
+#endif
+ (src, 0, dst, 0, sz);
+ }
+ }
+}
+
+Actual Results:
+[benm@Ben tmp]$ mcs bytebuff.cs /d:BUFFER /out:buffer.exe; mcs bytebuff.cs
+/out:arraycopy.exe
+[benm@Ben tmp]$ time mono buffer.exe ; time mono arraycopy.exe
+
+real 0m15.677s
+user 0m6.630s
+sys 0m0.150s
+
+real 0m7.572s
+user 0m3.280s
+sys 0m0.060s
+
+
+Expected Results:
+The Buffer version should be as fast as, or preferably faster than, the
+Array version
+
+How often does this happen?
+Always
+
+Additional Information:
+I tested this on MS windows and by eye, the performance was better with the
+Buffer version (there is sadly no timer on Windows, so I wasnt able to
+tell). However, there was not a visiable gap as in Mono.