Skip to content

Commit 3ca9d01

Browse files
committed
Add benchmark
1 parent 88e8987 commit 3ca9d01

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

mst_test.go

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package graph
22

33
import (
4+
"math/rand"
45
"testing"
56
)
67

@@ -30,3 +31,16 @@ func TestMST(t *testing.T) {
3031
t.Errorf("MST: %s", mess)
3132
}
3233
}
34+
35+
func BenchmarkMST(b *testing.B) {
36+
n := 1000
37+
b.StopTimer()
38+
g := New(n)
39+
for i := 0; i < n; i++ {
40+
g.AddBoth(rand.Intn(n), rand.Intn(n))
41+
}
42+
b.StartTimer()
43+
for i := 0; i < b.N; i++ {
44+
_ = MST(g)
45+
}
46+
}

0 commit comments

Comments
 (0)