Find duration of command
This commit is contained in:
parent
9c323e5923
commit
183f57f239
1 changed files with 17 additions and 0 deletions
|
|
@ -2,9 +2,26 @@ package main
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
"time"
|
||||
)
|
||||
|
||||
type data struct {
|
||||
i, j int
|
||||
}
|
||||
|
||||
func main() {
|
||||
var N = 40000000
|
||||
var structure []data
|
||||
for i := 0; i < N; i++ {
|
||||
value := int(i)
|
||||
structure = append(structure, data{value, value})
|
||||
}
|
||||
|
||||
start := time.Now()
|
||||
runtime.GC()
|
||||
duration := time.Since(start)
|
||||
|
||||
fmt.Println("It took GC()", duration, "to finish")
|
||||
_ = structure[0]
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue