himorime

command module
v0.1.0 Latest Latest
Warning

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

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

README

himorime

UnitTest E2E tested with atago Lint Go Reference

himorime answers one question for a command-line program: does this CLI stay within its performance budget? It measures latency, throughput, CPU time and peak memory from a himorime.yaml kept in your repository, checks your budgets, compares against a Git base revision, and fails CI when performance gets worse. The same file and the same command work on your laptop and in GitHub Actions.

himorime is a sister project of atago: atago tests what a CLI does, himorime tests how fast and how lean it does it.

Install

$ go install github.com/nao1215/himorime@latest

Prebuilt archives and .deb, .rpm and .apk packages for Linux, macOS and Windows are on GitHub Releases; see Installation.

A suite

# 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"}}

Run it

$ himorime run
suite: mytool (himorime.yaml)
latency
BENCHMARK          COMMAND   MEDIAN     MEAN  STDDEV  RELATIVE  RESULT
parse large input  mytool   81.88ms  82.53ms  4.45ms     1.00x  PASS

throughput
BENCHMARK          COMMAND       MEDIAN         MEAN          MIN  RESULT
parse large input  mytool   189.22MiB/s  188.19MiB/s  165.48MiB/s  PASS

cpu
BENCHMARK          COMMAND     USER  SYSTEM    TOTAL  UTILIZATION  RESULT
parse large input  mytool   79.03ms  3.03ms  82.07ms       100.4%  OVER BUDGET

memory
BENCHMARK          COMMAND  PEAK RSS       MAX  RESULT
parse large input  mytool   10.57MiB  10.57MiB  PASS

budgets
BENCHMARK          COMMAND  METRIC                    BUDGET     MEASURED  RESULT
parse large input  mytool   latency p95          <= 100.00ms      89.64ms  PASS
parse large input  mytool   throughput median  >= 50.00MiB/s  189.22MiB/s  PASS
parse large input  mytool   cpu total median      <= 80.00ms      82.07ms  FAIL
parse large input  mytool   peak rss max         <= 64.00MiB     10.57MiB  PASS
  parse large input / mytool: budget cpu total median <= 80.00ms not met (measured 82.07ms)

0 passed, 1 over budget · 1 benchmark · seed 6177791292910221 · exit 1
himorime: exit 1: performance check failed: a budget or regression threshold was violated (the measurement itself succeeded)

(Explanatory lines under each table are omitted here.) Reports are also available as JSON with every raw sample, long-format CSV, Markdown and a GitHub Actions job summary.

To compare your working tree, uncommitted changes included, with main on every metric:

$ himorime compare --against main

Each revision runs its own build or scripts, and each metric can gate the result or, with regression.<metric>.gate: false, only be reported.

The same suite in 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
      - uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
        with:
          go-version: stable
      - run: go install github.com/nao1215/himorime@latest
      # 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.

himorime and atago

atago checks that a CLI behaves as expected: exit codes, output, files. himorime checks that it performs as expected: latency, throughput, CPU time and memory within budget. They are meant to be used side by side.

Documentation

https://nao1215.github.io/himorime/ — getting started, configuration, metrics, reports, regression detection, cookbook, exit codes. Linux, macOS and Windows on amd64 and arm64 are supported; what each metric covers per 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) from Demon's Souls, who manages the player's stats through leveling. The name also fits the tool's role of measuring performance stats and detecting 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