From 14b67bc0ffd7a3ee8fc4629e8cfb93e33e095858 Mon Sep 17 00:00:00 2001 From: Paweł Bylica Date: Fri, 13 Feb 2015 14:56:27 +0100 Subject: Performance tests: more ackermann calls, fibonacci. - ackermann(3, 1) - ackermann(3, 2) - fibonacci(10) - fibonacci(16) Contract code included: PerformanceTester.sol --- PerformaceTester.sol | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 PerformaceTester.sol (limited to 'PerformaceTester.sol') diff --git a/PerformaceTester.sol b/PerformaceTester.sol new file mode 100644 index 00000000..3b1202ce --- /dev/null +++ b/PerformaceTester.sol @@ -0,0 +1,17 @@ +contract PerformanceTester { + function ackermann(uint m, uint n) returns (uint) { + if (m == 0) + return n + 1; + + if (n == 0) + return ackermann(m - 1, 1); + + return ackermann(m - 1, ackermann(m, n - 1)); + } + + function fibonacci(uint n) returns (uint) { + if (n == 0 || n == 1) + return n; + return fibonacci(n - 1) + fibonacci(n - 2); + } +} \ No newline at end of file -- cgit