August 2019
Beginner to intermediate
798 pages
17h 2m
English
Now we can rewrite sliceGC.go, mapNoStar.go, mapStar.go, and mapSplit.go from the previous chapter and get more accurate results from them without the need to use the time(1) UNIX command-line utility. Actually, the only thing that needs to be done in each one of these files is embed the call to runtime.GC() between time.Now() and time.Since(), and print the results. The updated versions of sliceGC.go, mapNoStar.go, mapStar.go, and mapSplit.go will be called sliceGCTime.go, mapNoStarTime.go, mapStarTime.go, and mapSplitTime.go, respectively.
Executing the updated versions will generate the following output:
$ go run sliceGCTime.go It took GC() 281.563µs to finish $ go run mapNoStarTime.go ...
Read now
Unlock full access