@monstermann/tinybench-pretty-printer
Version:
Customizable pretty-printer for tinybench benchmarks
109 lines (108 loc) • 5.79 kB
text/typescript
/// <reference types="node" resolution-mode="require"/>
import { Column, Columns, DefaultColumn, MarginOptions, NameOptions, OpsOptions, SamplesOptions, SortMethod, SummaryOptions, TimeOptions } from "./types.mjs";
import * as _monstermann_tables0 from "@monstermann/tables";
import { Borders, CreateCliTableConfig, Style } from "@monstermann/tables";
import { Bench } from "tinybench";
//#region src/tinybenchPrinter.d.ts
interface TinybenchPrinter<T extends string> {
borders: (borders: Borders) => TinybenchPrinter<T>;
borderStyle: (style: Style[]) => TinybenchPrinter<T>;
column: <U extends string>(name: U, column: Column) => TinybenchPrinter<T | U>;
locales: (locales: Intl.LocalesArgument) => TinybenchPrinter<T>;
margin: (options: MarginOptions) => TinybenchPrinter<T>;
maxWidth: (maxWidth: number) => TinybenchPrinter<T>;
name: (options: NameOptions) => TinybenchPrinter<T>;
ops: (options: OpsOptions) => TinybenchPrinter<T>;
order: (order: T[]) => TinybenchPrinter<T>;
padding: (padding: number) => TinybenchPrinter<T>;
prepareTableConfig: (bench: Bench) => CreateCliTableConfig<T>;
samples: (options: SamplesOptions) => TinybenchPrinter<T>;
sort: (method: SortMethod) => TinybenchPrinter<T>;
stdout: (stdout: NodeJS.WriteStream) => TinybenchPrinter<T>;
summary: (options: SummaryOptions) => TinybenchPrinter<T>;
time: (options: TimeOptions) => TinybenchPrinter<T>;
toCli: (bench: Bench) => string;
toMarkdown: (bench: Bench) => string;
useBottomBorder: (use: boolean) => TinybenchPrinter<T>;
useDividerBorder: (use: boolean) => TinybenchPrinter<T>;
useHeader: (use: boolean) => TinybenchPrinter<T>;
useHeaderSeparator: (use: boolean) => TinybenchPrinter<T>;
useLeftBorder: (use: boolean) => TinybenchPrinter<T>;
useRightBorder: (use: boolean) => TinybenchPrinter<T>;
useRowSeparator: (use: boolean) => TinybenchPrinter<T>;
useTopBorder: (use: boolean) => TinybenchPrinter<T>;
}
type Config = {
borders?: Borders;
borderStyle?: Style[];
columns: Columns<string>;
locales?: Intl.LocalesArgument;
maxWidth?: number;
order: string[];
padding?: number;
sort?: SortMethod;
stdout?: NodeJS.WriteStream;
useBottomBorder?: boolean;
useDividerBorder?: boolean;
useHeader?: boolean;
useHeaderSeparator?: boolean;
useLeftBorder?: boolean;
useRightBorder?: boolean;
useRowSeparator?: boolean;
useTopBorder?: boolean;
};
declare class TinybenchPrinterImpl {
config: Config;
constructor(config: Config);
borders(borders: Borders): TinybenchPrinterImpl;
borderStyle(borderStyle: Style[]): TinybenchPrinterImpl;
column(name: string, column: Column): TinybenchPrinterImpl;
locales(locales: Intl.LocalesArgument): TinybenchPrinterImpl;
margin(options: MarginOptions): TinybenchPrinterImpl;
maxWidth(maxWidth: number): TinybenchPrinterImpl;
merge(config: Partial<Config>): TinybenchPrinterImpl;
name(options: NameOptions): TinybenchPrinterImpl;
ops(options: OpsOptions): TinybenchPrinterImpl;
order(order: string[]): TinybenchPrinterImpl;
padding(padding: number): TinybenchPrinterImpl;
prepareTableConfig(bench: Bench): {
columnAlignments: Record<string, _monstermann_tables0.Alignment>;
columns: string[];
columnStyles: Record<string, ("bold" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough" | "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite")[]>;
headerAlignments: Record<string, _monstermann_tables0.Alignment>;
headerStyles: Record<string, ("bold" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough" | "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite")[]>;
headerTitles: Record<string, string>;
rows: Record<string, string>[];
borders?: Borders | undefined;
borderStyle?: ("bold" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough" | "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite")[] | undefined;
maxWidth?: number | undefined;
padding?: number | undefined;
stdout?: NodeJS.WriteStream | undefined;
useBottomBorder?: boolean | undefined;
useDividerBorder?: boolean | undefined;
useHeader?: boolean | undefined;
useHeaderSeparator?: boolean | undefined;
useLeftBorder?: boolean | undefined;
useRightBorder?: boolean | undefined;
useRowSeparator?: boolean | undefined;
useTopBorder?: boolean | undefined;
} | undefined;
samples(options: SamplesOptions): TinybenchPrinterImpl;
sort(sort: SortMethod): TinybenchPrinterImpl;
stdout(stdout: NodeJS.WriteStream): TinybenchPrinterImpl;
summary(options: SummaryOptions): TinybenchPrinterImpl;
time(options: TimeOptions): TinybenchPrinterImpl;
toCli(bench: Bench): string;
toMarkdown(bench: Bench): string;
useBottomBorder(useBottomBorder: boolean): TinybenchPrinterImpl;
useDividerBorder(useDividerBorder: boolean): TinybenchPrinterImpl;
useHeader(useHeader: boolean): TinybenchPrinterImpl;
useHeaderSeparator(useHeaderSeparator: boolean): TinybenchPrinterImpl;
useLeftBorder(useLeftBorder: boolean): TinybenchPrinterImpl;
useRightBorder(useRightBorder: boolean): TinybenchPrinterImpl;
useRowSeparator(useRowSeparator: boolean): TinybenchPrinterImpl;
useTopBorder(useTopBorder: boolean): TinybenchPrinterImpl;
}
declare const tinybenchPrinter: TinybenchPrinter<DefaultColumn>;
//#endregion
export { TinybenchPrinter, TinybenchPrinterImpl, tinybenchPrinter };