| Server IP : 217.160.0.212 / Your IP : 216.73.216.141 Web Server : Apache System : Linux www 6.18.51-i1-ampere #1196 SMP Fri Sep 11 20:43:55 CEST 2026 aarch64 User : sws1073854427 ( 1073854427) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib/go/src/cmd/link/internal/benchmark/ |
Upload File : |
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package benchmark
import (
"testing"
)
func TestMakeBenchString(t *testing.T) {
tests := []struct {
have, want string
}{
{"foo", "BenchmarkFoo"},
{" foo ", "BenchmarkFoo"},
{"foo bar", "BenchmarkFooBar"},
}
for i, test := range tests {
if v := makeBenchString(test.have); test.want != v {
t.Errorf("test[%d] makeBenchString(%q) == %q, want %q", i, test.have, v, test.want)
}
}
}
func TestPProfFlag(t *testing.T) {
tests := []struct {
name string
want bool
}{
{"", false},
{"foo", true},
}
for i, test := range tests {
b := New(GC, test.name)
if v := b.shouldPProf(); test.want != v {
t.Errorf("test[%d] shouldPProf() == %v, want %v", i, v, test.want)
}
}
}
func TestPProfNames(t *testing.T) {
want := "foo_BenchmarkTest.cpuprof"
if v := makePProfFilename("foo", "test", "cpuprof"); v != want {
t.Errorf("makePProfFilename() == %q, want %q", v, want)
}
}
// Ensure that public APIs work with a nil Metrics object.
func TestNilBenchmarkObject(t *testing.T) {
var b *Metrics
b.Start("TEST")
b.Report(nil)
}