[Mono-bugs] [Bug 60725][Wis] New - Use frndint for Math.Round

bugzilla-daemon@bugzilla.ximian.com bugzilla-daemon@bugzilla.ximian.com
Thu, 24 Jun 2004 20:58:20 -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 bmaurer@users.sf.net.

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

--- shadow/60725	2004-06-24 20:58:20.000000000 -0400
+++ shadow/60725.tmp.2642	2004-06-24 20:58:20.000000000 -0400
@@ -0,0 +1,41 @@
+Bug#: 60725
+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: Use frndint for Math.Round
+
+Microsoft's jit uses the `frndint' instruction to implement
+System.Math.Round. They are thus 10x faster in this test case:
+
+using System;
+class T {
+	static void Main ()
+	{
+		int x = Environment.TickCount;
+		double d1 = 1.0D, d2 = 2.0D, d3 = 3.0D, d4 = 4.0D;
+		for (int i = 0; i < 5000000; i++) {
+			d1 = Math.Round(d2); d2 = Math.Round(d3); d3 = Math.Round(d4); d4 =
+Math.Round(d1);
+			d1 = Math.Round(d2); d2 = Math.Round(d3); d3 = Math.Round(d4); d4 =
+Math.Round(d1);
+			d1 = Math.Round(d2); d2 = Math.Round(d3); d3 = Math.Round(d4); d4 =
+Math.Round(d1);
+			d1 = Math.Round(d2); d2 = Math.Round(d3); d3 = Math.Round(d4); d4 =
+Math.Round(d1);
+		}
+		
+		Console.WriteLine (Environment.TickCount - x);
+	}
+}