package main

import (
	"fmt"
	"time"
)

func assertEqual(a interface{}, b interface{}) {
	if a != b {
		panic(fmt.Sprint("Expected ", a, ", but got ", b))
	}
}

func fib(n int) int {
	if n < 2 {
		return 1
	}
	return fib(n - 1) + fib(n - 2)
}

func addOne(x int) int {
	return x + 1
}

func testMath() {
	assertEqual(2, 1 + 1)
}

func testFunctions() {
	assertEqual(5, fib(4))
	assertEqual(2, addOne(1))
}

func main() {
	start := time.Now()
	testMath()
	testFunctions()
	fmt.Print("Pass!")
	fmt.Println("Took ", time.Since(start))
}
package main

import (
	"fmt"
	"time"
)

func assertEqual(a interface{}, b interface{}) {
	if a != b {
		panic(fmt.Sprint("Expected ", a, ", but got ", b))
	}
}

func fib(n int) int {
	if n < 2 {
		return 1
	}
	return fib(n - 1) + fib(n - 2)
}

func addOne(x int) int {
	return x + 1
}

func testMath() {
	assertEqual(2, 1 + 1)
}

func testFunctions() {
	assertEqual(5, fib(4))
	assertEqual(2, addOne(1))
}

func testPerf() {
	start := time.Now()
	fib(10)
	fmt.Println("Took ", time.Since(start))
}

func main() {
	testMath()
	testFunctions()
	testPerf()
	fmt.Print("Pass!")
}
--- 
+++ 
@@ -31,15 +31,10 @@
 	assertEqual(2, addOne(1))
 }
 
-func testPerf() {
+func main() {
 	start := time.Now()
-	fib(10)
+	testMath()
+	testFunctions()
+	fmt.Print("Pass!")
 	fmt.Println("Took ", time.Since(start))
 }
-
-func main() {
-	testMath()
-	testFunctions()
-	testPerf()
-	fmt.Print("Pass!")
-}
Change timing to time the full test suite

This gives us a more realistic picture of the perf of native vs interpreted
code.
