Skip to content

ci: add benchmark workflow - #33

Merged
Kikobeats merged 1 commit into
masterfrom
Kikobeats/benchmark-baseline-2
Oct 28, 2026
Merged

Kikobeats merged 1 commit into
masterfrom
Kikobeats/benchmark-baseline-2

Conversation

@Kikobeats

@Kikobeats Kikobeats commented Oct 28, 2026 •

Copy link
Copy Markdown
Owner

Adds benchmark/index.js and a benchmark workflow that compares base and head on the same runner. Library source is untouched.

Cases

Each case takes one of the three ways getEncoding can resolve a charset, using the existing test fixtures.

  • decode windows-1250 from content-type decodes the 130 KB rp.pl.html with the charset in the header. This measures the charset lookup plus iconv.decode on a large single-byte document.
  • decode shift_jis from meta charset passes a bare text/html, so the charset comes from the document head of 51242_54045.html.
  • infer shift_jis with jschardet uses the same document with its encoding=/charset= declarations stripped (built at startup with iconv-lite), so every call falls through to jschardet.detect. This is the slowest path, about 0.8 ms per 6.6 KB call.

Local baseline

Node v24.16.0, arm64, median of 7 samples per run.

case run 1 run 2 run 3
decode windows-1250 from content-type 170.1 ms 168.6 ms 168.5 ms
decode shift_jis from meta charset 165.4 ms 168.6 ms 170.7 ms
infer shift_jis with jschardet 241.3 ms 236.7 ms 228.9 ms

Locally, npm test (lint + tests) passes and node benchmark/index.js exits 0. Each case asserts its own output, so a broken function cannot report a fast time. The workflow comes from the shared generator: it runs base and head alternately for 5 rounds on one runner and comments the medians on the PR.

🤖 Generated with Claude Code


Note

Low Risk
Only CI, benchmark harness, and ignore/script wiring; no changes to index.js or runtime behavior.

Overview
Adds automated performance regression tracking on pull requests without changing library code.

A new benchmark/index.js runs three timed scenarios against existing test fixtures, each hitting a different charset resolution path in the exported decoder (header Content-Type, HTML meta charset, and jschardet inference). Samples use GC between runs, verify decoded output on every iteration, and write benchmark-output.json for CI.

.github/workflows/benchmark.yml checks out base and head, installs with pnpm, alternates node benchmark/index.js for five rounds on one runner, merges medians into a base vs head table (with graceful skip if base has no benchmark), and posts results via benchmark-action/github-action-benchmark. npm run benchmark and .gitignore entries for generated benchmark artifacts complete the setup.

Reviewed by Cursor Bugbot for commit 6ed34ac. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features
    • Added automated performance comparisons for UTF-8 conversion across several character-encoding scenarios.
    • Reports include repeated-run median and range timings, plus comparisons between the base and proposed versions in pull request summaries.
    • Comparisons still report proposed-version results when base-version results are unavailable.

Cases:
- decode windows-1250 from content-type
- decode shift_jis from meta charset
- infer shift_jis with jschardet

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Walkthrough

Adds a benchmark runner for three UTF-8 conversion cases and a pull-request workflow that compares head and base results. The workflow aggregates timings and reports the comparison in the step summary and, for eligible pull requests, a benchmark comment.

Changes: Benchmark runner and pull-request reporting

Layer / File(s) Summary
Benchmark cases and result generation
benchmark/index.js, package.json, .gitignore
Adds three decoding cases, verification, warm-up and timed samples, median and range reporting, and JSON output. Adds the benchmark script and ignores generated output and cache files.
Pull-request comparison and reporting
.github/workflows/benchmark.yml
Checks out and installs head and base, runs alternating benchmark rounds, aggregates results, and reports comparisons. Base failures omit base results; head benchmark failures fail the job. The comment action runs only for pull requests from the same repository.

Priority: Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Other

Sequence Diagram(s)

sequenceDiagram
  participant Workflow as benchmark.yml workflow
  participant Checkout as Head and base checkout/install
  participant Runner as benchmark/index.js
  participant Aggregation as Result aggregation
  participant Comment as Benchmark comment action
  Workflow->>Checkout: Check out and install head and base
  Workflow->>Runner: Run benchmark cases
  Runner-->>Workflow: Write benchmark results
  Workflow->>Aggregation: Combine results and calculate ranges
  Aggregation-->>Workflow: Provide head output and benchmark data
  Workflow->>Comment: Submit head output and cached benchmark data
Loading
Merge Risk: Low · up to 6ed34

This adds a benchmark script and a PR benchmark workflow without touching library code. If the base benchmark breaks, the report will show no baseline and the job will still pass. The warning is visible in the run output, so this is a bounded clarity issue to be aware of, not a merge blocker.

Pre-merge checks: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly identifies the main CI change: adding a benchmark workflow. It is concise and related to the pull request.
Docstring Coverage Passed No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

No eligible functions found in the changed files. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 0 functions across 1 files. (3 skipped: 3 unsupported.)

Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coveralls

Copy link
Copy Markdown

Coverage Status

Coverage is 92.593% — Kikobeats/benchmark-baseline-2 into master. No base build found for master.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔇 Additional comments: 1
.github/workflows/benchmark.yml-59-60: 1

59-60: Major · Functional Correctness · Quick win

⚠️ Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Fail the comparison when an available base benchmark fails.

If the base benchmark exists but fails in every round, run_side logs warnings and continues. The Compare step then reports head results without a base value, and the job succeeds. The base install fallback at Lines 45–48 has the same effect. Skip comparison only when the base has no benchmark; otherwise fail on install or benchmark errors.


Review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a7359175-2755-4f05-8606-8c8f82ccedb0
Commits

Reviewing files that changed from the base of the PR and between da0ff97 and 6ed34ac.

Files selected for processing: 4
  • .github/workflows/benchmark.yml
  • .gitignore
  • benchmark/index.js
  • package.json

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

@Kikobeats
Kikobeats merged commit dd99c96 into master Oct 28, 2026
5 checks passed
@Kikobeats
Kikobeats deleted the Kikobeats/benchmark-baseline-2 branch October 28, 2026 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants