himorime

command module
v0.3.0 Latest Latest
Warning

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

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

README

UnitTest E2E tested with atago measured with himorime 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

The setup-himorime action installs a checksum-verified release before the benchmark runs.

# 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:

# Fork PRs run with read-only permissions and receive no comment.
permissions:
  contents: read

jobs:
  benchmark:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pull-requests: write
    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@30710690b8b2dc8c61df8bf289f5bb899af3fbfa # v0.1.2 + automatic comments
      # Compares the pull request base and head, writes a job summary and
      # annotations, and saves JSON for setup-himorime's automatic comment.
      - run: himorime ci --format json --output "$RUNNER_TEMP/himorime.json"
      # Keep raw samples available from the run page.
      - uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
        if: always()
        with:
          name: himorime-report
          path: ${{ runner.temp }}/himorime.json
          retention-days: 7

setup-himorime automatically posts a short problem-only comment on same-repository pull requests.

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.

Measuring programs you did not write

himorime measures a command, so a third-party tool is measured like your own. The suites in bench/thirdparty do that with real programs, and they are written to be read and copied: real-world suites says what each one shows and what was made equal between the programs.

Suite Programs
json jq, gojq, jaq
compression gzip, bzip2, xz

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 火防女 (himorime), the maiden who tends the fire: in Demon's Souls, 黒衣の火防女, the Maiden in Black in English, 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
bench
thirdparty/gen command
Command gen writes the input files the third-party benchmark suites measure over, so that no sample data from anyone else's project is committed here.
Command gen writes the input files the third-party benchmark suites measure over, so that no sample data from anyone else's project is committed here.
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.
diag
Package diag defines the stable error codes printed by himorime.
Package diag defines the stable error codes printed by himorime.
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