mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
Add parsers golang benchmarks.
Add parser and formatting for golang benchmarks for docker benchmarks. Change adds a library for printing and parsing Test parameters and metrics. Benchmarks use the library to print parameters in the Benchmark title (e.g. the name field in b.Run()), and to report CustomMetrics. Parser uses the library to parse printed data from benchmark output and put it into BigQuery structs. PiperOrigin-RevId: 336365628
This commit is contained in:
committed by
gVisor bot
parent
6df400dfb6
commit
b576de907c
@@ -71,8 +71,15 @@ func BenchmarkSysbench(b *testing.B) {
|
||||
defer machine.CleanUp()
|
||||
|
||||
for _, tc := range testCases {
|
||||
b.Run(tc.name, func(b *testing.B) {
|
||||
|
||||
param := tools.Parameter{
|
||||
Name: "testname",
|
||||
Value: tc.name,
|
||||
}
|
||||
name, err := tools.ParametersToName(param)
|
||||
if err != nil {
|
||||
b.Fatalf("Failed to parse params: %v", err)
|
||||
}
|
||||
b.Run(name, func(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
sysbench := machine.GetContainer(ctx, b)
|
||||
defer sysbench.CleanUp(ctx)
|
||||
|
||||
@@ -66,7 +66,15 @@ func BenchmarkRedis(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
|
||||
for _, operation := range operations {
|
||||
b.Run(operation, func(b *testing.B) {
|
||||
param := tools.Parameter{
|
||||
Name: "operation",
|
||||
Value: operation,
|
||||
}
|
||||
name, err := tools.ParametersToName(param)
|
||||
if err != nil {
|
||||
b.Fatalf("Failed to parse paramaters: %v", err)
|
||||
}
|
||||
b.Run(name, func(b *testing.B) {
|
||||
server := serverMachine.GetContainer(ctx, b)
|
||||
defer server.CleanUp(ctx)
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
|
||||
"gvisor.dev/gvisor/pkg/test/dockerutil"
|
||||
"gvisor.dev/gvisor/test/benchmarks/harness"
|
||||
"gvisor.dev/gvisor/test/benchmarks/tools"
|
||||
)
|
||||
|
||||
// Note: CleanCache versions of this test require running with root permissions.
|
||||
@@ -46,17 +47,36 @@ func runBuildBenchmark(b *testing.B, image, workdir, target string) {
|
||||
// Dimensions here are clean/dirty cache (do or don't drop caches)
|
||||
// and if the mount on which we are compiling is a tmpfs/bind mount.
|
||||
benchmarks := []struct {
|
||||
name string
|
||||
clearCache bool // clearCache drops caches before running.
|
||||
tmpfs bool // tmpfs will run compilation on a tmpfs.
|
||||
}{
|
||||
{name: "CleanCache", clearCache: true, tmpfs: false},
|
||||
{name: "DirtyCache", clearCache: false, tmpfs: false},
|
||||
{name: "CleanCacheTmpfs", clearCache: true, tmpfs: true},
|
||||
{name: "DirtyCacheTmpfs", clearCache: false, tmpfs: true},
|
||||
{clearCache: true, tmpfs: false},
|
||||
{clearCache: false, tmpfs: false},
|
||||
{clearCache: true, tmpfs: true},
|
||||
{clearCache: false, tmpfs: true},
|
||||
}
|
||||
for _, bm := range benchmarks {
|
||||
b.Run(bm.name, func(b *testing.B) {
|
||||
pageCache := tools.Parameter{
|
||||
Name: "page_cache",
|
||||
Value: "clean",
|
||||
}
|
||||
if bm.clearCache {
|
||||
pageCache.Value = "dirty"
|
||||
}
|
||||
|
||||
filesystem := tools.Parameter{
|
||||
Name: "filesystem",
|
||||
Value: "bind",
|
||||
}
|
||||
if bm.tmpfs {
|
||||
filesystem.Value = "tmpfs"
|
||||
}
|
||||
name, err := tools.ParametersToName(pageCache, filesystem)
|
||||
if err != nil {
|
||||
b.Fatalf("Failed to parse parameters: %v", err)
|
||||
}
|
||||
|
||||
b.Run(name, func(b *testing.B) {
|
||||
// Grab a container.
|
||||
ctx := context.Background()
|
||||
container := machine.GetContainer(ctx, b)
|
||||
|
||||
@@ -67,8 +67,19 @@ func BenchmarkFio(b *testing.B) {
|
||||
|
||||
for _, fsType := range []mount.Type{mount.TypeBind, mount.TypeTmpfs} {
|
||||
for _, tc := range testCases {
|
||||
testName := strings.Title(tc.Test) + strings.Title(string(fsType))
|
||||
b.Run(testName, func(b *testing.B) {
|
||||
operation := tools.Parameter{
|
||||
Name: "operation",
|
||||
Value: tc.Test,
|
||||
}
|
||||
filesystem := tools.Parameter{
|
||||
Name: "filesystem",
|
||||
Value: string(fsType),
|
||||
}
|
||||
name, err := tools.ParametersToName(operation, filesystem)
|
||||
if err != nil {
|
||||
b.Fatalf("Failed to parser paramters: %v", err)
|
||||
}
|
||||
b.Run(name, func(b *testing.B) {
|
||||
ctx := context.Background()
|
||||
container := machine.GetContainer(ctx, b)
|
||||
defer container.CleanUp(ctx)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/test/dockerutil"
|
||||
@@ -31,33 +31,15 @@ var httpdDocs = map[string]string{
|
||||
"10Mb": "latin10240k.txt",
|
||||
}
|
||||
|
||||
// BenchmarkHttpdConcurrency iterates the concurrency argument and tests
|
||||
// how well the runtime under test handles requests in parallel.
|
||||
func BenchmarkHttpdConcurrency(b *testing.B) {
|
||||
// The test iterates over client concurrency, so set other parameters.
|
||||
concurrency := []int{1, 25, 50, 100, 1000}
|
||||
|
||||
for _, c := range concurrency {
|
||||
b.Run(fmt.Sprintf("%d", c), func(b *testing.B) {
|
||||
hey := &tools.Hey{
|
||||
Requests: c * b.N,
|
||||
Concurrency: c,
|
||||
Doc: httpdDocs["10Kb"],
|
||||
}
|
||||
runHttpd(b, hey, false /* reverse */)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkHttpdDocSize iterates over different sized payloads, testing how
|
||||
// well the runtime handles sending different payload sizes.
|
||||
func BenchmarkHttpdDocSize(b *testing.B) {
|
||||
// BenchmarkHttpd iterates over different sized payloads and concurrency, testing
|
||||
// how well the runtime handles sending different payload sizes.
|
||||
func BenchmarkHttpd(b *testing.B) {
|
||||
benchmarkHttpdDocSize(b, false /* reverse */)
|
||||
}
|
||||
|
||||
// BenchmarkReverseHttpdDocSize iterates over different sized payloads, testing
|
||||
// BenchmarkReverseHttpd iterates over different sized payloads, testing
|
||||
// how well the runtime handles receiving different payload sizes.
|
||||
func BenchmarkReverseHttpdDocSize(b *testing.B) {
|
||||
func BenchmarkReverseHttpd(b *testing.B) {
|
||||
benchmarkHttpdDocSize(b, true /* reverse */)
|
||||
}
|
||||
|
||||
@@ -65,10 +47,22 @@ func BenchmarkReverseHttpdDocSize(b *testing.B) {
|
||||
// for each size.
|
||||
func benchmarkHttpdDocSize(b *testing.B, reverse bool) {
|
||||
b.Helper()
|
||||
for name, filename := range httpdDocs {
|
||||
for size, filename := range httpdDocs {
|
||||
concurrency := []int{1, 25, 50, 100, 1000}
|
||||
for _, c := range concurrency {
|
||||
b.Run(fmt.Sprintf("%s_%d", name, c), func(b *testing.B) {
|
||||
fsize := tools.Parameter{
|
||||
Name: "filesize",
|
||||
Value: size,
|
||||
}
|
||||
concurrency := tools.Parameter{
|
||||
Name: "concurrency",
|
||||
Value: strconv.Itoa(c),
|
||||
}
|
||||
name, err := tools.ParametersToName(fsize, concurrency)
|
||||
if err != nil {
|
||||
b.Fatalf("Failed to parse parameters: %v", err)
|
||||
}
|
||||
b.Run(name, func(b *testing.B) {
|
||||
hey := &tools.Hey{
|
||||
Requests: c * b.N,
|
||||
Concurrency: c,
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
||||
"gvisor.dev/gvisor/pkg/test/dockerutil"
|
||||
@@ -31,30 +31,6 @@ var nginxDocs = map[string]string{
|
||||
"10Mb": "latin10240k.txt",
|
||||
}
|
||||
|
||||
// BenchmarkNginxConcurrency iterates the concurrency argument and tests
|
||||
// how well the runtime under test handles requests in parallel.
|
||||
func BenchmarkNginxConcurrency(b *testing.B) {
|
||||
concurrency := []int{1, 25, 100, 1000}
|
||||
for _, c := range concurrency {
|
||||
for _, tmpfs := range []bool{true, false} {
|
||||
fs := "Gofer"
|
||||
if tmpfs {
|
||||
fs = "Tmpfs"
|
||||
}
|
||||
name := fmt.Sprintf("%d_%s", c, fs)
|
||||
b.Run(name, func(b *testing.B) {
|
||||
hey := &tools.Hey{
|
||||
Requests: c * b.N,
|
||||
Concurrency: c,
|
||||
Doc: nginxDocs["10kb"], // see Dockerfile '//images/benchmarks/nginx' and httpd_test.
|
||||
}
|
||||
runNginx(b, hey, false /* reverse */, tmpfs /* tmpfs */)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// BenchmarkNginxDocSize iterates over different sized payloads, testing how
|
||||
// well the runtime handles sending different payload sizes.
|
||||
func BenchmarkNginxDocSize(b *testing.B) {
|
||||
@@ -71,15 +47,32 @@ func BenchmarkReverseNginxDocSize(b *testing.B) {
|
||||
// benchmarkNginxDocSize iterates through all doc sizes, running subbenchmarks
|
||||
// for each size.
|
||||
func benchmarkNginxDocSize(b *testing.B, reverse, tmpfs bool) {
|
||||
for name, filename := range nginxDocs {
|
||||
for size, filename := range nginxDocs {
|
||||
concurrency := []int{1, 25, 50, 100, 1000}
|
||||
for _, c := range concurrency {
|
||||
fs := "Gofer"
|
||||
if tmpfs {
|
||||
fs = "Tmpfs"
|
||||
fsize := tools.Parameter{
|
||||
Name: "filesize",
|
||||
Value: size,
|
||||
}
|
||||
benchName := fmt.Sprintf("%s_%d_%s", name, c, fs)
|
||||
b.Run(benchName, func(b *testing.B) {
|
||||
|
||||
threads := tools.Parameter{
|
||||
Name: "concurrency",
|
||||
Value: strconv.Itoa(c),
|
||||
}
|
||||
|
||||
fs := tools.Parameter{
|
||||
Name: "filesystem",
|
||||
Value: "bind",
|
||||
}
|
||||
if tmpfs {
|
||||
fs.Value = "tmpfs"
|
||||
}
|
||||
name, err := tools.ParametersToName(fsize, threads, fs)
|
||||
if err != nil {
|
||||
b.Fatalf("Failed to parse parameters: %v", err)
|
||||
}
|
||||
|
||||
b.Run(name, func(b *testing.B) {
|
||||
hey := &tools.Hey{
|
||||
Requests: c * b.N,
|
||||
Concurrency: c,
|
||||
|
||||
@@ -15,7 +15,7 @@ package network
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -31,7 +31,15 @@ import (
|
||||
func BenchmarkNode(b *testing.B) {
|
||||
concurrency := []int{1, 5, 10, 25}
|
||||
for _, c := range concurrency {
|
||||
b.Run(fmt.Sprintf("Concurrency%d", c), func(b *testing.B) {
|
||||
param := tools.Parameter{
|
||||
Name: "concurrency",
|
||||
Value: strconv.Itoa(c),
|
||||
}
|
||||
name, err := tools.ParametersToName(param)
|
||||
if err != nil {
|
||||
b.Fatalf("Failed to parse parameters: %v", err)
|
||||
}
|
||||
b.Run(name, func(b *testing.B) {
|
||||
hey := &tools.Hey{
|
||||
Requests: b.N * c, // Requests b.N requests per thread.
|
||||
Concurrency: c,
|
||||
|
||||
@@ -16,6 +16,7 @@ package network
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
@@ -31,7 +32,15 @@ import (
|
||||
func BenchmarkRuby(b *testing.B) {
|
||||
concurrency := []int{1, 5, 10, 25}
|
||||
for _, c := range concurrency {
|
||||
b.Run(fmt.Sprintf("Concurrency%d", c), func(b *testing.B) {
|
||||
param := tools.Parameter{
|
||||
Name: "concurrency",
|
||||
Value: strconv.Itoa(c),
|
||||
}
|
||||
name, err := tools.ParametersToName(param)
|
||||
if err != nil {
|
||||
b.Fatalf("Failed to parse parameters: %v", err)
|
||||
}
|
||||
b.Run(name, func(b *testing.B) {
|
||||
hey := &tools.Hey{
|
||||
Requests: b.N * c, // b.N requests per thread.
|
||||
Concurrency: c,
|
||||
|
||||
@@ -4,12 +4,14 @@ package(licenses = ["notice"])
|
||||
|
||||
go_library(
|
||||
name = "tools",
|
||||
testonly = 1,
|
||||
srcs = [
|
||||
"ab.go",
|
||||
"fio.go",
|
||||
"hey.go",
|
||||
"iperf.go",
|
||||
"meminfo.go",
|
||||
"parser_util.go",
|
||||
"redis.go",
|
||||
"sysbench.go",
|
||||
"tools.go",
|
||||
|
||||
@@ -46,18 +46,21 @@ func (a *ApacheBench) Report(b *testing.B, output string) {
|
||||
b.Logf("failed to parse transferrate: %v", err)
|
||||
}
|
||||
b.ReportMetric(transferRate*1024, "transfer_rate_b/s") // Convert from Kb/s to b/s.
|
||||
ReportCustomMetric(b, transferRate*1024, "transfer_rate" /*metric name*/, "bytes_per_second" /*unit*/)
|
||||
|
||||
latency, err := a.parseLatency(output)
|
||||
if err != nil {
|
||||
b.Logf("failed to parse latency: %v", err)
|
||||
}
|
||||
b.ReportMetric(latency/1000, "mean_latency_secs") // Convert from ms to s.
|
||||
ReportCustomMetric(b, latency/1000, "mean_latency" /*metric name*/, "s" /*unit*/)
|
||||
|
||||
reqPerSecond, err := a.parseRequestsPerSecond(output)
|
||||
if err != nil {
|
||||
b.Logf("failed to parse requests per second: %v", err)
|
||||
}
|
||||
b.ReportMetric(reqPerSecond, "requests_per_second")
|
||||
ReportCustomMetric(b, reqPerSecond, "requests_per_second" /*metric name*/, "QPS" /*unit*/)
|
||||
}
|
||||
|
||||
var transferRateRE = regexp.MustCompile(`Transfer rate:\s+(\d+\.?\d+?)\s+\[Kbytes/sec\]\s+received`)
|
||||
|
||||
@@ -56,13 +56,13 @@ func (f *Fio) Report(b *testing.B, output string) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to parse bandwidth from %s with: %v", output, err)
|
||||
}
|
||||
b.ReportMetric(bw, "bandwidth_b/s") // in b/s.
|
||||
ReportCustomMetric(b, bw, "bandwidth" /*metric name*/, "bytes_per_second" /*unit*/)
|
||||
|
||||
iops, err := f.parseIOps(output, isRead)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to parse iops from %s with: %v", output, err)
|
||||
}
|
||||
b.ReportMetric(iops, "iops")
|
||||
ReportCustomMetric(b, iops, "io_ops" /*metric name*/, "ops_per_second" /*unit*/)
|
||||
}
|
||||
|
||||
// parseBandwidth reports the bandwidth in b/s.
|
||||
|
||||
@@ -43,13 +43,13 @@ func (h *Hey) Report(b *testing.B, output string) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to parse requests per second: %v", err)
|
||||
}
|
||||
b.ReportMetric(requests, "requests_per_second")
|
||||
ReportCustomMetric(b, requests, "requests_per_second" /*metric name*/, "QPS" /*unit*/)
|
||||
|
||||
ave, err := h.parseAverageLatency(output)
|
||||
if err != nil {
|
||||
b.Fatalf("failed to parse average latency: %v", err)
|
||||
}
|
||||
b.ReportMetric(ave, "average_latency_secs")
|
||||
ReportCustomMetric(b, ave, "average_latency" /*metric name*/, "s" /*unit*/)
|
||||
}
|
||||
|
||||
var heyReqPerSecondRE = regexp.MustCompile(`Requests/sec:\s*(\d+\.?\d+?)\s+`)
|
||||
|
||||
@@ -42,7 +42,7 @@ func (i *Iperf) Report(b *testing.B, output string) {
|
||||
if err != nil {
|
||||
b.Fatalf("failed to parse bandwitdth from %s: %v", output, err)
|
||||
}
|
||||
b.ReportMetric(bW*1024, "bandwidth_b/s") // Convert from Kb/s to b/s.
|
||||
ReportCustomMetric(b, bW*1024, "bandwidth" /*metric name*/, "bytes_per_second" /*unit*/)
|
||||
}
|
||||
|
||||
// bandwidth parses the Bandwidth number from an iperf report. A sample is below.
|
||||
|
||||
@@ -45,7 +45,7 @@ func (*Meminfo) Report(b *testing.B, before, after string) {
|
||||
b.Fatalf("could not parse before value %s: %v", before, err)
|
||||
}
|
||||
val := 1024 * ((beforeVal - afterVal) / float64(b.N))
|
||||
b.ReportMetric(val, "average_container_size_bytes")
|
||||
ReportCustomMetric(b, val, "average_container_size" /*metric name*/, "bytes" /*units*/)
|
||||
}
|
||||
|
||||
var memInfoRE = regexp.MustCompile(`MemAvailable:\s*(\d+)\skB\n`)
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
// Copyright 2020 The gVisor Authors.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package tools
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// Parameter is a test parameter.
|
||||
type Parameter struct {
|
||||
Name string
|
||||
Value string
|
||||
}
|
||||
|
||||
// Output is parsed and split by these values. Make them illegal in input methods.
|
||||
// We are constrained on what characters these can be by 1) docker's allowable
|
||||
// container names, 2) golang allowable benchmark names, and 3) golangs allowable
|
||||
// charecters in b.ReportMetric calls.
|
||||
var illegalChars = regexp.MustCompile(`[/\.]`)
|
||||
|
||||
// ParametersToName joins parameters into a string format for parsing.
|
||||
// It is meant to be used for t.Run() calls in benchmark tools.
|
||||
func ParametersToName(params ...Parameter) (string, error) {
|
||||
var strs []string
|
||||
for _, param := range params {
|
||||
if illegalChars.MatchString(param.Name) || illegalChars.MatchString(param.Value) {
|
||||
return "", fmt.Errorf("params Name: %q and Value: %q cannot container '.' or '/'", param.Name, param.Value)
|
||||
}
|
||||
strs = append(strs, strings.Join([]string{param.Name, param.Value}, "."))
|
||||
}
|
||||
return strings.Join(strs, "/"), nil
|
||||
}
|
||||
|
||||
// NameToParameters parses the string created by ParametersToName and returns
|
||||
// it as a set of Parameters.
|
||||
// Example: BenchmarkRuby/server_threads.1/doc_size.16KB-6
|
||||
// The parameter part of this benchmark is:
|
||||
// "server_threads.1/doc_size.16KB" (BenchmarkRuby is the name, and 6 is GOMAXPROCS)
|
||||
// This function will return a slice with two parameters ->
|
||||
// {Name: server_threads, Value: 1}, {Name: doc_size, Value: 16KB}
|
||||
func NameToParameters(name string) ([]*Parameter, error) {
|
||||
var params []*Parameter
|
||||
for _, cond := range strings.Split(name, "/") {
|
||||
cs := strings.Split(cond, ".")
|
||||
switch len(cs) {
|
||||
case 1:
|
||||
params = append(params, &Parameter{Name: cond, Value: cond})
|
||||
case 2:
|
||||
params = append(params, &Parameter{Name: cs[0], Value: cs[1]})
|
||||
default:
|
||||
return nil, fmt.Errorf("failed to parse param: %s", cond)
|
||||
}
|
||||
}
|
||||
return params, nil
|
||||
}
|
||||
|
||||
// ReportCustomMetric reports a metric in a set format for parsing.
|
||||
func ReportCustomMetric(b *testing.B, value float64, name, unit string) {
|
||||
if illegalChars.MatchString(name) || illegalChars.MatchString(unit) {
|
||||
b.Fatalf("name: %q and unit: %q cannot contain '/' or '.'", name, unit)
|
||||
}
|
||||
nameUnit := strings.Join([]string{name, unit}, ".")
|
||||
b.ReportMetric(value, nameUnit)
|
||||
}
|
||||
|
||||
// Metric holds metric data parsed from a string based on the format
|
||||
// ReportMetric.
|
||||
type Metric struct {
|
||||
Name string
|
||||
Unit string
|
||||
Sample float64
|
||||
}
|
||||
|
||||
// ParseCustomMetric parses a metric reported with ReportCustomMetric.
|
||||
func ParseCustomMetric(value, metric string) (*Metric, error) {
|
||||
sample, err := strconv.ParseFloat(value, 64)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to parse value: %v", err)
|
||||
}
|
||||
nameUnit := strings.Split(metric, ".")
|
||||
if len(nameUnit) != 2 {
|
||||
return nil, fmt.Errorf("failed to parse metric: %s", metric)
|
||||
}
|
||||
return &Metric{Name: nameUnit[0], Unit: nameUnit[1], Sample: sample}, nil
|
||||
}
|
||||
@@ -49,7 +49,7 @@ func (r *Redis) Report(b *testing.B, output string) {
|
||||
if err != nil {
|
||||
b.Fatalf("parsing result %s failed with err: %v", output, err)
|
||||
}
|
||||
b.ReportMetric(result, r.Operation) // operations per second
|
||||
ReportCustomMetric(b, result, r.Operation /*metric_name*/, "QPS" /*unit*/)
|
||||
}
|
||||
|
||||
// parseOperation grabs the metric operations per second from redis-benchmark output.
|
||||
|
||||
@@ -80,7 +80,7 @@ func (s *SysbenchCPU) Report(b *testing.B, output string) {
|
||||
if err != nil {
|
||||
b.Fatalf("parsing CPU events from %s failed: %v", output, err)
|
||||
}
|
||||
b.ReportMetric(result, "cpu_events_per_second")
|
||||
ReportCustomMetric(b, result, "cpu_events" /*metric name*/, "events_per_second" /*unit*/)
|
||||
}
|
||||
|
||||
var cpuEventsPerSecondRE = regexp.MustCompile(`events per second:\s*(\d*.?\d*)\n`)
|
||||
@@ -144,7 +144,7 @@ func (s *SysbenchMemory) Report(b *testing.B, output string) {
|
||||
if err != nil {
|
||||
b.Fatalf("parsing result %s failed with err: %v", output, err)
|
||||
}
|
||||
b.ReportMetric(result, "operations_per_second")
|
||||
ReportCustomMetric(b, result, "memory_operations" /*metric name*/, "ops_per_second" /*unit*/)
|
||||
}
|
||||
|
||||
var memoryOperationsRE = regexp.MustCompile(`Total\soperations:\s+\d*\s*\((\d*\.\d*)\sper\ssecond\)`)
|
||||
@@ -198,19 +198,19 @@ func (s *SysbenchMutex) Report(b *testing.B, output string) {
|
||||
if err != nil {
|
||||
b.Fatalf("parsing result %s failed with err: %v", output, err)
|
||||
}
|
||||
b.ReportMetric(result, "average_execution_time_secs")
|
||||
ReportCustomMetric(b, result, "average_execution_time" /*metric name*/, "s" /*unit*/)
|
||||
|
||||
result, err = s.parseDeviation(output)
|
||||
if err != nil {
|
||||
b.Fatalf("parsing result %s failed with err: %v", output, err)
|
||||
}
|
||||
b.ReportMetric(result, "stdev_execution_time_secs")
|
||||
ReportCustomMetric(b, result, "stddev_execution_time" /*metric name*/, "s" /*unit*/)
|
||||
|
||||
result, err = s.parseLatency(output)
|
||||
if err != nil {
|
||||
b.Fatalf("parsing result %s failed with err: %v", output, err)
|
||||
}
|
||||
b.ReportMetric(result/1000, "average_latency_secs")
|
||||
ReportCustomMetric(b, result/1000, "average_latency" /*metric name*/, "s" /*unit*/)
|
||||
}
|
||||
|
||||
var executionTimeRE = regexp.MustCompile(`execution time \(avg/stddev\):\s*(\d*.?\d*)/(\d*.?\d*)`)
|
||||
|
||||
@@ -6,5 +6,8 @@ go_library(
|
||||
name = "bigquery",
|
||||
testonly = 1,
|
||||
srcs = ["bigquery.go"],
|
||||
visibility = [
|
||||
"//:sandbox",
|
||||
],
|
||||
deps = ["@com_google_cloud_go_bigquery//:go_default_library"],
|
||||
)
|
||||
|
||||
@@ -30,11 +30,20 @@ import (
|
||||
// Benchmark is the top level structure of recorded benchmark data. BigQuery
|
||||
// will infer the schema from this.
|
||||
type Benchmark struct {
|
||||
Name string `bq:"name"`
|
||||
Timestamp time.Time `bq:"timestamp"`
|
||||
Official bool `bq:"official"`
|
||||
Metric []*Metric `bq:"metric"`
|
||||
Metadata *Metadata `bq:"metadata"`
|
||||
Name string `bq:"name"`
|
||||
Condition []*Condition `bq:"condition"`
|
||||
Timestamp time.Time `bq:"timestamp"`
|
||||
Official bool `bq:"official"`
|
||||
Metric []*Metric `bq:"metric"`
|
||||
Metadata *Metadata `bq:"metadata"`
|
||||
}
|
||||
|
||||
// Condition represents qualifiers for the benchmark. For example:
|
||||
// Get_Pid/1/real_time would have Benchmark Name "Get_Pid" with "1"
|
||||
// and "real_time" parameters as conditions.
|
||||
type Condition struct {
|
||||
Name string `bq:"name"`
|
||||
Value string `bq:"value"`
|
||||
}
|
||||
|
||||
// Metric holds the actual metric data and unit information for this benchmark.
|
||||
@@ -79,6 +88,14 @@ func InitBigQuery(ctx context.Context, projectID, datasetID, tableID string) err
|
||||
return nil
|
||||
}
|
||||
|
||||
// AddCondition adds a condition to an existing Benchmark.
|
||||
func (bm *Benchmark) AddCondition(name, value string) {
|
||||
bm.Condition = append(bm.Condition, &Condition{
|
||||
Name: name,
|
||||
Value: value,
|
||||
})
|
||||
}
|
||||
|
||||
// AddMetric adds a metric to an existing Benchmark.
|
||||
func (bm *Benchmark) AddMetric(metricName, unit string, sample float64) {
|
||||
m := &Metric{
|
||||
@@ -90,7 +107,7 @@ func (bm *Benchmark) AddMetric(metricName, unit string, sample float64) {
|
||||
}
|
||||
|
||||
// NewBenchmark initializes a new benchmark.
|
||||
func NewBenchmark(name string, official bool) *Benchmark {
|
||||
func NewBenchmark(name string, iters int, official bool) *Benchmark {
|
||||
return &Benchmark{
|
||||
Name: name,
|
||||
Timestamp: time.Now().UTC(),
|
||||
@@ -103,7 +120,7 @@ func NewBenchmark(name string, official bool) *Benchmark {
|
||||
func SendBenchmarks(ctx context.Context, benchmarks []*Benchmark, projectID, datasetID, tableID string) error {
|
||||
client, err := bq.NewClient(ctx, projectID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Failed to initialize client on project: %s: %v", projectID, err)
|
||||
return fmt.Errorf("failed to initialize client on project: %s: %v", projectID, err)
|
||||
}
|
||||
defer client.Close()
|
||||
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
load("//tools:defs.bzl", "go_library", "go_test")
|
||||
|
||||
package(licenses = ["notice"])
|
||||
|
||||
go_test(
|
||||
name = "parsers_test",
|
||||
size = "small",
|
||||
srcs = ["go_parser_test.go"],
|
||||
library = ":parsers",
|
||||
deps = [
|
||||
"//tools/bigquery",
|
||||
"@com_github_google_go_cmp//cmp:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "parsers",
|
||||
testonly = 1,
|
||||
srcs = [
|
||||
"go_parser.go",
|
||||
],
|
||||
visibility = ["//:sandbox"],
|
||||
deps = [
|
||||
"//test/benchmarks/tools",
|
||||
"//tools/bigquery",
|
||||
],
|
||||
)
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user