gvisorgvisor.dev/gvisor/tools/bigquery Index | Files

package bigquery

import "gvisor.dev/gvisor/tools/bigquery"

Package bigquery defines a BigQuery schema for benchmarks.

This package contains a schema for BigQuery and methods for publishing benchmark data into tables.

Index

Functions

func InitBigQuery

func InitBigQuery(ctx context.Context, projectID, datasetID, tableID string, opts []option.ClientOption) error

InitBigQuery initializes a BigQuery dataset/table in the project. If the dataset/table already exists, it is not duplicated.

func SendBenchmarks

func SendBenchmarks(ctx context.Context, suite *Suite, projectID, datasetID, tableID string, opts []option.ClientOption) error

SendBenchmarks sends the slice of benchmarks to the BigQuery dataset/table.

Types

type Benchmark

type Benchmark struct {
	Name      string       `bq:"name"`
	Condition []*Condition `bq:"cond"`
	Metric    []*Metric    `bq:"metric"`
}

Benchmark represents an individual benchmark in a suite.

func NewBenchmark

func NewBenchmark(name string, iters int) *Benchmark

NewBenchmark initializes a new benchmark.

func NewBenchmarkWithMetric

func NewBenchmarkWithMetric(name, metric, unit string, value float64) *Benchmark

NewBenchmarkWithMetric creates a new sending to BigQuery, initialized with a single iteration and single metric.

func (*Benchmark) AddCondition

func (bm *Benchmark) AddCondition(name, value string)

AddCondition adds a condition to an existing Benchmark.

func (*Benchmark) AddMetric

func (bm *Benchmark) AddMetric(metricName, unit string, sample float64)

AddMetric adds a metric to an existing Benchmark.

func (*Benchmark) String

func (bm *Benchmark) String() string

String implements the String method for Benchmark

type Condition

type Condition struct {
	Name  string `bq:"name"`
	Value string `bq:"value"`
}

Condition represents qualifiers for the benchmark or suite. For example: Get_Pid/1/real_time would have Benchmark Name "Get_Pid" with "1" and "real_time" parameters as conditions. Suite conditions include information such as the CL number and platform name.

func NewCondition

func NewCondition(name, value string) *Condition

NewCondition returns a new Condition with the given name and value.

func (*Condition) String

func (c *Condition) String() string

type Metric

type Metric struct {
	Name   string  `bq:"name"`
	Unit   string  `bq:"unit"`
	Sample float64 `bq:"sample"`
}

Metric holds the actual metric data and unit information for this benchmark.

func (*Metric) String

func (m *Metric) String() string

type Suite

type Suite struct {
	Name       string       `bq:"name"`
	Conditions []*Condition `bq:"conditions"`
	Benchmarks []*Benchmark `bq:"benchmarks"`
	Official   bool         `bq:"official"`
	Timestamp  time.Time    `bq:"timestamp"`
}

Suite is the top level structure for a benchmark run. BigQuery will infer the schema from this.

func NewSuite

func NewSuite(name string, official bool) *Suite

NewSuite initializes a new Suite.

func (*Suite) Benchstat

func (s *Suite) Benchstat(includeCondition func(string) bool) string

Benchstat returns a benchstat-formatted output string. See https://pkg.go.dev/golang.org/x/perf/cmd/benchstat `includeCondition` returns whether a `Condition` name should be included as part of the benchmark name. If nil, all conditions are included.

func (*Suite) String

func (s *Suite) String() string

Source Files

bigquery.go

Version
v0.0.0-20250605235530-a6711d1e1dc6 (latest)
Published
Jun 5, 2025
Platform
linux/amd64
Imports
9 packages
Last checked
4 hours ago

Tools for package owners.