We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent f5a1472 commit 88e8987Copy full SHA for 88e8987
1 file changed
path_test.go
@@ -1,6 +1,7 @@
1
package graph
2
3
import (
4
+ "math/rand"
5
"testing"
6
)
7
@@ -48,3 +49,17 @@ func TestShortestPath(t *testing.T) {
48
49
t.Errorf("ShortestPath->dist %s", mess)
50
}
51
52
+
53
+func BenchmarkShortestPaths(b *testing.B) {
54
+ n := 1000
55
+ b.StopTimer()
56
+ g := New(n)
57
+ for i := 0; i < n; i++ {
58
+ g.Add(0, rand.Intn(n))
59
+ g.Add(rand.Intn(n), rand.Intn(n))
60
+ }
61
+ b.StartTimer()
62
+ for i := 0; i < b.N; i++ {
63
+ _, _ = ShortestPaths(g, 0)
64
65
+}
0 commit comments