]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.2] test/mapnan: use time.Now instead of syscall.Getrusage
authorAndrew Gerrand <adg@golang.org>
Fri, 1 Nov 2013 00:15:02 +0000 (11:15 +1100)
committerAndrew Gerrand <adg@golang.org>
Fri, 1 Nov 2013 00:15:02 +0000 (11:15 +1100)
««« CL 15570046 / 9169cb38c3e8
test/mapnan: use time.Now instead of syscall.Getrusage

Avoids a dependency on a somewhat nonstandard part of package syscall.

R=golang-dev, dave, r
CC=golang-dev
https://golang.org/cl/15570046
»»»

R=golang-dev
CC=golang-dev
https://golang.org/cl/19960045

test/mapnan.go

index 60b35fbeaf48e7960ef40c2301c2ea2753dbe893..f081cab01d4b3a522b11c6112de38bc524fe2861 100644 (file)
@@ -13,17 +13,13 @@ import (
        "fmt"
        "math"
        "time"
-       "syscall"
 )
 
 func main() {
 
        // Test that NaNs in maps don't go quadratic.
        t := func(n int) time.Duration {
-               var u0 syscall.Rusage
-               if err := syscall.Getrusage(0,  &u0); err != nil {
-                       panic(err)
-               }
+               t1 := time.Now()
                m := map[float64]int{}
                nan := math.NaN()
                for i := 0; i < n; i++ {
@@ -32,11 +28,7 @@ func main() {
                if len(m) != n {
                        panic("wrong size map after nan insertion")
                }
-               var u1 syscall.Rusage
-               if err := syscall.Getrusage(0,  &u1); err != nil {
-                       panic(err)
-               }
-               return time.Duration(u1.Utime.Nano() - u0.Utime.Nano())
+               return time.Since(t1)
        }
 
        // Depending on the machine and OS, this test might be too fast