Build Systems With Go: Everything a Gopher must know by Tirado Juan M

Build Systems With Go: Everything a Gopher must know by Tirado Juan M

Author:Tirado, Juan M. [Tirado, Juan M.]
Language: eng
Format: epub
Published: 2021-04-07T16:00:00+00:00


1 package example_01

2

3 import (

4 “math/rand”

5 “testing”

6 “time”

7 )

8

9 func BuildGraph(vertices int, edges int) [][]int {

10 graph := make([][]int, vertices)

11 for i:=0;i<len(graph);i++{

12 graph[i] = make([]int,0,1)

13 }

14 for i:=0;i<edges;i++{

15 from := rand.Intn(vertices)

16 to := rand.Intn(vertices)

17 graph[from]=append(graph[from],to)

18 }

19

20 return graph

21 }

22

23 func BenchmarkGraph(b *testing.B) {

24 rand.Seed(time.Now().UnixNano())

25 for i:=0;i<b.N;i++ {

26 BuildGraph(100,20000)

27 }

28 }



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.