bench

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 12, 2026 License: Apache-2.0 Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package bench is the dispatch bench (T07): dispatch situations written as data, each with the decision expected by hand, and what a contender decides for each. The plain Go scheduler (internal/dispatch) is the first contender; a local model would read the same cases. go tool task bench-dispatch prints the table.

Index

Constants

View Source
const (
	Start = "start"
	Wait  = "wait"
	Fail  = "fail"
)

The decisions a case expects for a planned task.

Variables

This section is empty.

Functions

func Table

func Table(w io.Writer, contender string, results []Result)

Table writes the results as a Markdown table, then the score.

Types

type Answer

type Answer struct {
	Code     string
	Decision string // start, wait or fail
	Reason   string // why it waits or fails
}

Answer is what a contender decided for one planned task.

type Case

type Case struct {
	// Name says what the case checks.
	Name string `json:"name"`
	// Machine is what the machine allows; absent, nothing limits.
	Machine *Machine `json:"machine,omitempty"`
	// Wishes, oldest first.
	Wishes []Wish `json:"wishes"`
	// Projects; a project not listed is not in Git.
	Projects []Project `json:"projects,omitempty"`
	// Tasks, oldest first.
	Tasks []Task `json:"tasks"`
	// Gates held now. The Go scheduler does not read them: a worker waits for its gate when it runs the command.
	Gates []Gate `json:"gates,omitempty"`
	// Expect is the decision for each planned or resuming task, by code: start, wait or fail.
	Expect map[string]string `json:"expect"`
}

Case is a dispatch situation and the decision expected for each of its planned tasks.

func Cases

func Cases() ([]Case, error)

Cases are the bench's cases.

func (Case) Situation

func (c Case) Situation() *dispatch.Situation

Situation is the case as the Go scheduler reads it. The tasks are a second apart, in the order of the case.

type Gate

type Gate struct {
	Name   string `json:"name"`
	Holder string `json:"holder"`
}

Gate is a gate held in a case.

type Machine

type Machine struct {
	Slots    int    `json:"slots"`
	Running  int    `json:"running"`
	Pressure string `json:"pressure,omitempty"`
}

Machine is what the machine allows in a case.

type Project

type Project struct {
	ID  string `json:"id"`
	Git bool   `json:"git"`
}

Project is a project of a case.

type Result

type Result struct {
	Case    Case
	Answers []Answer // in the order the contender decided
	// Wrong are the codes whose decision is not the expected one.
	Wrong []string
	// PerPass is the time of one pass over the case, the situation built included.
	PerPass time.Duration
}

Result is a contender's answer to a case.

func Go

func Go(c Case, budget time.Duration) Result

Go runs the plain Go scheduler on the case, then times passes over it for about budget.

func (Result) Right

func (r Result) Right() bool

Right tells whether every decision is the expected one.

type Task

type Task struct {
	Code string `json:"code"`
	Wish string `json:"wish"`
	// Project; empty outside any project.
	Project string `json:"project,omitempty"`
	// Status: planned (pending, started by the scheduler), resuming (cut short, started again by the scheduler),
	// running, waiting (for its edit question), done, failed, stopped or interrupted.
	Status    string   `json:"status"`
	DependsOn []string `json:"depends_on,omitempty"`
	// Scopes are the write scopes; none is the whole folder.
	Scopes []string `json:"scopes,omitempty"`
	// ForkOf is the code of the task this one forks: an interrupted task forked is resumed as its fork.
	ForkOf string `json:"fork_of,omitempty"`
	// Role: investigator.
	Role string `json:"role,omitempty"`
	// Correction indicates a correction worker.
	Correction bool `json:"correction,omitempty"`
	// Review indicates a review worker.
	Review bool `json:"review,omitempty"`
}

Task is a task of a case. Its code is its identifier, unique in the case.

type Wish

type Wish struct {
	ID string `json:"id"`
	// State: active (the default), paused or granted.
	State string `json:"state,omitempty"`
	// Rank among the active wishes, 1 first; 0 comes after the ranked ones.
	Rank int32 `json:"rank,omitempty"`
}

Wish is a wish of a case.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL