@aklinker1/tinybench-report
v1.0.6
Published
Generate custom reports and charts for tinybench results
Readme
@aklinker1/tinybench-report
Generate custom reports and charts for tinybench results.
bun add @aklinker1/tinybench-report
deno add @aklinker1/tinybench-reportFeatures
- Markdown report
- SVG charts
- Build-your-own report
Usage
Markdown Report
import { MarkdownReport } from "@aklinker1/tinybench-report";
import { Bench } from "tinybench";
// 1. Create a report
const report = new MarkdownReport();
// 2. Add benchmarks to the report
const bench1 = new Bench({ ... });
report.add(bench1);
const bench2 = new Bench({ ... });
report.add(bench2);
// 3. Optional - run any benchmarks that weren't manually ran
await report.run();
// 4. Render and save the report
const files = report.render();
await report.write(".", files);SVG Chart
import { renderSvg } from "@aklinker1/tinybench-report/svg";
import { Bench } from "tinybench";
// 1. Create and run your benchmark
const bench1 = new Bench({ ... });
report.add(bench1);
// 2. Render the SVG chart
const svg: string = renderSvg(bench1);
// 3. Save it or do whatever
await writeFile("chart.svg", svg)Custom Report
import { Report, ReportOptions, BenchOptions } from "@aklinker1/tinybench-report";
// If you need custom options, add to the basic options
type CustomReportOptions = ReportOptions & {};
type CustomBenchOptions = BenchOptions & {};
class MyReport extends Report<CustomReportOptions, CustomBenchOptions> {
// ...
}You can implement any functions you want - the markdown report exposes two functions (render and write), but you can do whatever you want.
- Use
this.benchesto access each bench and it's options
