[svn:parrot] r43072 - trunk/examples/benchmarks

NotFound at svn.parrot.org NotFound at svn.parrot.org
Tue Dec 15 17:06:35 UTC 2009


Author: NotFound
Date: Tue Dec 15 17:06:33 2009
New Revision: 43072
URL: https://trac.parrot.org/parrot/changeset/43072

Log:
[examples] C# version of benchmark/fib, diakopter++

Added:
   trunk/examples/benchmarks/fib.cs

Added: trunk/examples/benchmarks/fib.cs
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ trunk/examples/benchmarks/fib.cs	Tue Dec 15 17:06:33 2009	(r43072)
@@ -0,0 +1,26 @@
+// (C) 2009, Parrot Foundation
+// $Id: $
+
+// Fibonacci Benchmark
+
+using System;
+using System.Diagnostics;
+
+namespace str
+{
+    class MainClass
+    {
+        public static void Main (string[] args)
+        {
+            var sw = new Stopwatch(); sw.Start();
+            var n = args.Length > 0 ? Int32.Parse(args[0]) : 28;
+            var result = _fib(n);
+            sw.Stop();
+            Console.WriteLine ("fib(" + n + ") = " + result);
+            Console.WriteLine ("Elapsed: " + sw.Elapsed);
+        }
+        static int _fib (int n) {
+            return n < 2 ? n : _fib(n - 1) + _fib(n - 2);
+        }
+    }
+}


More information about the parrot-commits mailing list