himorime

command module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MIT Imports: 3 Imported by: 0

README

UnitTest E2E tested with atago Lint Go Reference

himorime logo

himorime measures how fast and how lean a command-line program is: latency, throughput, CPU time and peak memory, from a YAML file kept in your repository. It runs your actual binary, in any language, checks the numbers against budgets, and compares a change with its Git base revision, so a pull request that makes the program slower fails CI. The same file and command work on your laptop and in GitHub Actions.

himorime is the sister project of atago: atago tests what a CLI does, himorime tests how it performs.

Documentation: https://nao1215.github.io/himorime/

First run

If you have Go and Git, paste this. init writes a suite that measures git --version, and run measures it:

go run github.com/nao1215/himorime@latest init
go run github.com/nao1215/himorime@latest run
suite: my benchmarks (himorime.yaml)
latency
BENCHMARK    COMMAND    MEDIAN      MEAN   STDDEV  RELATIVE  RESULT
git startup  git      529.50µs  548.45µs  75.40µs     1.00x  PASS

budgets
BENCHMARK    COMMAND  METRIC           BUDGET  MEASURED  RESULT
git startup  git      latency median  < 1.00s  529.50µs  PASS

1 passed · 1 benchmark · seed 477717617585165 · exit 0

Then point himorime.yaml at your own tool. This suite builds it, measures one input on every metric, and sets a budget for each:

# yaml-language-server: $schema=https://raw.githubusercontent.com/nao1215/himorime/main/schema/himorime.schema.json
version: "1"

suite:
  name: mytool

build:
  command: [go, build, -o, "${artifact}", ./cmd/mytool]

benchmarks:
  - name: parse large input
    metrics:
      throughput:
        work:
          file_size: testdata/large.jsonl
      cpu: true
      memory: true
    commands:
      mytool:
        command: ["${artifact}", testdata/large.jsonl]
    budget:
      mytool:
        latency: {p95: "<= 100ms"}
        throughput: {median: ">= 50MiB/s"}
        cpu: {total: {median: "<= 80ms"}}
        memory: {peak_rss: {max: "<= 64MiB"}}

himorime run exits 1 when a budget is missed. himorime compare --against main builds main in a temporary worktree and your working tree side by side, measures both in interleaved rounds, and exits 1 on a regression it is confident about. Reports are also available as JSON with every sample, CSV, Markdown and a GitHub Actions job summary, and a Markdown report can replace a marked section of a documentation page.

GitHub Actions

# Copy this file to .github/workflows/benchmark.yml.
# Recipe: fail a GitHub Actions job when a performance budget is violated.
# https://nao1215.github.io/himorime/cookbook/#fail-a-github-actions-job-when-a-performance-budget-is-violated
name: Benchmark

on:
  pull_request:

# Read-only: himorime needs no secret and no write token, so pull requests from
# forks run it safely. Do not use pull_request_target, which would run the
# pull request's code with the base repository's secrets.
permissions:
  contents: read

jobs:
  benchmark:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
        with:
          # The base commit must exist locally for the temporary worktree.
          fetch-depth: 0
          persist-credentials: false
      # Go builds the suite's program; drop it if your suite needs no Go.
      - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version: stable
      # Installs a prebuilt, checksum-verified himorime release.
      - uses: nao1215/setup-himorime@b2896dee554ef31ea979f0388d9be22779ce73a2 # v0.1.1
      # Finds the pull request's base commit from the event, compares it with
      # the checked-out head on every metric the suite measures, writes a
      # summary to the job page and annotations to the pull request, and
      # exits 1 on a missed budget or a confirmed regression. Exit 4 or 6
      # means the measurement itself failed, not the performance.
      - run: himorime ci

Exit status 1 means performance got worse; 4 and 6 mean the measurement itself failed. Shared runners are noisy: himorime interleaves the revisions, needs statistical confidence to call a regression, and reports anything it cannot tell apart from noise as inconclusive.

Install

go install github.com/nao1215/himorime@latest

On macOS, Homebrew works too:

brew install --cask nao1215/tap/himorime

The release page has prebuilt archives for Linux, macOS and Windows (amd64 and arm64) and .deb, .rpm and .apk packages for Linux. In GitHub Actions, setup-himorime installs a release. Building from source needs Go 1.26 or later.

Runs on Linux, macOS and Windows. What each metric covers on each OS is on the metrics page.

The name

himorime was inspired by atago, whose name is associated with protection from fire. It is named after the Maiden in Black (Hi no Bōjo) of Demon's Souls, who manages the player's stats through leveling, which fits a tool that measures performance stats and detects regressions.

License

MIT

Documentation

Overview

Command himorime checks whether command-line programs stay within their performance budgets: latency, throughput, CPU time and peak RSS, locally and in CI.

It measures commands declared in a versioned YAML suite, compares them with each other or with a Git base revision, checks absolute performance budgets, and exits non-zero on a confirmed regression. See https://nao1215.github.io/himorime/ for the documentation.

Directories

Path Synopsis
examples
tools/sleepy command
Command sleepy stands in for a program whose behavior you control: it sleeps or spins, optionally with jitter, optionally in child processes, then exits with the status you ask for.
Command sleepy stands in for a program whose behavior you control: it sleeps or spins, optionally with jitter, optionally in child processes, then exits with the status you ask for.
tools/wordcount command
Command wordcount counts lines, words and bytes, like a tiny wc.
Command wordcount counts lines, words and bytes, like a tiny wc.
internal
buildinfo
Package buildinfo reports the version himorime was built as.
Package buildinfo reports the version himorime was built as.
cli
Package cli implements himorime's command-line interface: subcommand dispatch, flag parsing, and the mapping of outcomes to exit codes.
Package cli implements himorime's command-line interface: subcommand dispatch, flag parsing, and the mapping of outcomes to exit codes.
config
Package config loads, validates and resolves himorime suite files.
Package config loads, validates and resolves himorime suite files.
docgen
Package docgen generates the parts of the documentation that restate the code: the command reference, the exit code table, the configuration field reference and defaults, and the example suites embedded in the Cookbook and README.
Package docgen generates the parts of the documentation that restate the code: the command reference, the exit code table, the configuration field reference and defaults, and the example suites embedded in the Cookbook and README.
envinfo
Package envinfo describes the machine a benchmark ran on, for reports.
Package envinfo describes the machine a benchmark ran on, for reports.
exitcode
Package exitcode defines himorime's exit statuses, a stable public contract.
Package exitcode defines himorime's exit statuses, a stable public contract.
ghactions
Package ghactions is the thin adapter between himorime and GitHub Actions.
Package ghactions is the thin adapter between himorime and GitHub Actions.
gitwt
Package gitwt prepares a Git revision for measurement in a temporary worktree without touching the user's working tree, index or branches.
Package gitwt prepares a Git revision for measurement in a temporary worktree without touching the user's working tree, index or branches.
metric
Package metric defines the performance metrics himorime collects: their names, units, the direction that counts as better, how raw samples are aggregated, and the typed quantities (durations, byte sizes, rates and percentages) that budgets and regression thresholds are written in.
Package metric defines the performance metrics himorime collects: their names, units, the direction that counts as better, how raw samples are aggregated, and the typed quantities (durations, byte sizes, rates and percentages) that budgets and regression thresholds are written in.
proc
Package proc starts processes so that a whole process tree can be stopped, and measures their wall-clock duration.
Package proc starts processes so that a whole process tree can be stopped, and measures their wall-clock duration.
redact
Package redact removes secret values from text himorime prints.
Package redact removes secret values from text himorime prints.
report
Package report turns raw measurements into judged results and renders them as a terminal table, JSON, CSV, Markdown or a GitHub Actions job summary.
Package report turns raw measurements into judged results and renders them as a terminal table, JSON, CSV, Markdown or a GitHub Actions job summary.
runner
Package runner executes benchmark suites and records raw samples.
Package runner executes benchmark suites and records raw samples.
stats
Package stats computes the summary statistics himorime reports and the bootstrap comparison it uses to classify a change between two revisions.
Package stats computes the summary statistics himorime reports and the bootstrap comparison it uses to classify a change between two revisions.
Package schema embeds the published JSON Schemas.
Package schema embeds the published JSON Schemas.
scripts
completions command
Command completions writes the shell completion scripts into completions/.
Command completions writes the shell completion scripts into completions/.
smoke command
Command smoke checks the artifacts GoReleaser wrote to a dist directory before they are published, on any operating system:
Command smoke checks the artifacts GoReleaser wrote to a dist directory before they are published, on any operating system:
test
e2e/helper command
Command helper is the portable stand-in program the end-to-end suite measures.
Command helper is the portable stand-in program the end-to-end suite measures.
e2e/run command
Command run executes the end-to-end suite.
Command run executes the end-to-end suite.

Jump to

Keyboard shortcuts

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