| 1 | // Copyright 2014 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | package mainscip-go gomod golang.org/x/tools . `golang.org/x/tools/cmd/benchcmp`/ |
| 6 | |
| 7 | import ( |
| 8 | "reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/" |
| 9 | "testingscip-go gomod github.com/golang/go/src go1.25.0 testing/" |
| 10 | |
| 11 | "golang.org/x/tools/benchmark/parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/" |
| 12 | ) |
| 13 | |
| 14 | func TestSelectBestscip-go gomod golang.org/x/tools . `golang.org/x/tools/cmd/benchcmp`/TestSelectBest().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 15 | have := parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.Setscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Set#{ |
| 16 | "Benchmark1": []*parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.Benchmarkscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#{ |
| 17 | { |
| 18 | Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Name.: "Benchmark1", |
| 19 | Nscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#N.: 10, NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#NsPerOp.: 100, Measuredscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Measured.: parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/NsPerOp., |
| 20 | Ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Ord.: 0, |
| 21 | }, |
| 22 | { |
| 23 | Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Name.: "Benchmark1", |
| 24 | Nscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#N.: 10, NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#NsPerOp.: 50, Measuredscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Measured.: parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/NsPerOp., |
| 25 | Ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Ord.: 3, |
| 26 | }, |
| 27 | }, |
| 28 | "Benchmark2": []*parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.Benchmarkscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#{ |
| 29 | { |
| 30 | Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Name.: "Benchmark2", |
| 31 | Nscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#N.: 10, NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#NsPerOp.: 60, Measuredscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Measured.: parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/NsPerOp., |
| 32 | Ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Ord.: 1, |
| 33 | }, |
| 34 | { |
| 35 | Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Name.: "Benchmark2", |
| 36 | Nscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#N.: 10, NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#NsPerOp.: 500, Measuredscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Measured.: parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/NsPerOp., |
| 37 | Ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Ord.: 2, |
| 38 | }, |
| 39 | }, |
| 40 | } |
| 41 | |
| 42 | want := parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.Setscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Set#{ |
| 43 | "Benchmark1": []*parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.Benchmarkscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#{ |
| 44 | { |
| 45 | Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Name.: "Benchmark1", |
| 46 | Nscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#N.: 10, NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#NsPerOp.: 50, Measuredscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Measured.: parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/NsPerOp., |
| 47 | Ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Ord.: 0, |
| 48 | }, |
| 49 | }, |
| 50 | "Benchmark2": []*parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.Benchmarkscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#{ |
| 51 | { |
| 52 | Namescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Name.: "Benchmark2", |
| 53 | Nscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#N.: 10, NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#NsPerOp.: 60, Measuredscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Measured.: parsescip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/.NsPerOpscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/NsPerOp., |
| 54 | Ordscip-go gomod golang.org/x/tools . `golang.org/x/tools/benchmark/parse`/Benchmark#Ord.: 1, |
| 55 | }, |
| 56 | }, |
| 57 | } |
| 58 | |
| 59 | selectBestscip-go gomod golang.org/x/tools . `golang.org/x/tools/cmd/benchcmp`/selectBest().(have) |
| 60 | if !reflectscip-go gomod github.com/golang/go/src go1.25.0 reflect/.DeepEqualscip-go gomod github.com/golang/go/src go1.25.0 reflect/DeepEqual().(want, have) { |
| 61 | t.Errorfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Errorf().("filtered bench set incorrectly, want %v have %v", want, have) |
| 62 | } |
| 63 | } |
| 64 | |
| 65 | func TestFormatNsscip-go gomod golang.org/x/tools . `golang.org/x/tools/cmd/benchcmp`/TestFormatNs().(t *testingscip-go gomod github.com/golang/go/src go1.25.0 testing/.Tscip-go gomod github.com/golang/go/src go1.25.0 testing/T#) { |
| 66 | tests := []struct { |
| 67 | input float64 |
| 68 | expected string |
| 69 | }{ |
| 70 | {input: 0, expected: "0.00"}, |
| 71 | {input: 0.2, expected: "0.20"}, |
| 72 | {input: 2, expected: "2.00"}, |
| 73 | {input: 2.2, expected: "2.20"}, |
| 74 | {input: 4, expected: "4.00"}, |
| 75 | {input: 16, expected: "16.0"}, |
| 76 | {input: 16.08, expected: "16.1"}, |
| 77 | {input: 128, expected: "128"}, |
| 78 | {input: 256.2, expected: "256"}, |
| 79 | } |
| 80 | |
| 81 | for _, tt := range tests { |
| 82 | actual := formatNsscip-go gomod golang.org/x/tools . `golang.org/x/tools/cmd/benchcmp`/formatNs().(tt.input) |
| 83 | if actual != tt.expected { |
| 84 | t.Fatalfscip-go gomod github.com/golang/go/src go1.25.0 testing/common#Fatalf().("%f. got %q, want %q", tt.input, actual, tt.expected) |
| 85 | } |
| 86 | } |
| 87 | } |