Skip to content
This repository has been archived by the owner on Jan 28, 2022. It is now read-only.

Commit

Permalink
restore grade_becnmarks_test.go
Browse files Browse the repository at this point in the history
  • Loading branch information
SVilgelm committed Oct 2, 2021
1 parent cb0af80 commit dbcbeba
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions grade_becnmarks_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import "testing"

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

var result int

func BenchmarkFib(b *testing.B) {
var r int
for n := 0; n < b.N; n++ {
r = fib(10)
}
result = r
}

func BenchmarkFibParallel(b *testing.B) {
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_ = fib(10)
}
})
}

0 comments on commit dbcbeba

Please sign in to comment.