@@ -121,7 +121,7 @@ function csig(p: number): string {
121121}
122122
123123/** Coefficient of variation as a percentage. */
124- function cvPct ( f : IFunctionStatistics ) : number {
124+ function cvPct ( f : Readonly < IFunctionStatistics > ) : number {
125125 return f . mean > 0 ? ( f . stdDev / f . mean ) * 100 : 0 ;
126126}
127127
@@ -157,7 +157,7 @@ function tpBar(ratio: number, w: number, rank: number): string {
157157 * Mini sparkline histogram of the sample distribution.
158158 * Bins are rendered with Unicode block elements ▁–█.
159159 */
160- function sparkline ( samples : number [ ] , w : number = 18 ) : string {
160+ function sparkline ( samples : readonly number [ ] , w : number = 18 ) : string {
161161 if ( samples . length < 2 ) return '' ;
162162 const sorted = [ ...samples ] . sort ( ( a , b ) => a - b ) ;
163163 const min = sorted [ 0 ] ;
@@ -193,7 +193,7 @@ function sparkline(samples: number[], w: number = 18): string {
193193 * - Median: bold white `│`
194194 */
195195function miniBox (
196- f : IFunctionStatistics ,
196+ f : Readonly < IFunctionStatistics > ,
197197 lo : number ,
198198 hi : number ,
199199 w : number = 32 ,
@@ -255,7 +255,7 @@ function secLine(label: string, totalW: number = 76): string {
255255// Sections
256256// ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
257257
258- function renderHeader ( suite : ISuiteReport ) : string [ ] {
258+ function renderHeader ( suite : Readonly < ISuiteReport > ) : string [ ] {
259259 const L : string [ ] = [ ] ;
260260 const { config } = suite ;
261261
@@ -296,8 +296,8 @@ function renderHeader(suite: ISuiteReport): string[] {
296296// ─── Winner announcement ─────────────────────────────────────────────────────
297297
298298function renderWinner (
299- fns : IFunctionStatistics [ ] ,
300- comps : IPairedComparison [ ] ,
299+ fns : readonly Readonly < IFunctionStatistics > [ ] ,
300+ comps : readonly Readonly < IPairedComparison > [ ] ,
301301) : string [ ] {
302302 if ( fns . length < 2 ) return [ ] ;
303303
@@ -353,7 +353,9 @@ function renderWinner(
353353
354354// ─── Leaderboard ─────────────────────────────────────────────────────────────
355355
356- function renderLeaderboard ( fns : IFunctionStatistics [ ] ) : string [ ] {
356+ function renderLeaderboard (
357+ fns : readonly Readonly < IFunctionStatistics > [ ] ,
358+ ) : string [ ] {
357359 const L : string [ ] = [ ] ;
358360 const fastest = fns [ 0 ] ;
359361
@@ -440,7 +442,9 @@ function renderLeaderboard(fns: IFunctionStatistics[]): string[] {
440442
441443// ─── Distribution (box plots + sparklines) ───────────────────────────────────
442444
443- function renderDistribution ( fns : IFunctionStatistics [ ] ) : string [ ] {
445+ function renderDistribution (
446+ fns : readonly Readonly < IFunctionStatistics > [ ] ,
447+ ) : string [ ] {
444448 const L : string [ ] = [ ] ;
445449
446450 L . push ( secLine ( 'Distribution' ) ) ;
@@ -498,7 +502,9 @@ function renderDistribution(fns: IFunctionStatistics[]): string[] {
498502
499503// ─── Detailed statistics table ───────────────────────────────────────────────
500504
501- function renderDetailedStats ( fns : IFunctionStatistics [ ] ) : string [ ] {
505+ function renderDetailedStats (
506+ fns : readonly Readonly < IFunctionStatistics > [ ] ,
507+ ) : string [ ] {
502508 const L : string [ ] = [ ] ;
503509
504510 L . push ( secLine ( 'Detailed Statistics' ) ) ;
@@ -552,13 +558,13 @@ function renderDetailedStats(fns: IFunctionStatistics[]): string[] {
552558// ─── Pairwise comparisons ────────────────────────────────────────────────────
553559
554560function renderComparisons (
555- fns : IFunctionStatistics [ ] ,
556- comps : IPairedComparison [ ] ,
561+ fns : readonly Readonly < IFunctionStatistics > [ ] ,
562+ comps : readonly Readonly < IPairedComparison > [ ] ,
557563) : string [ ] {
558564 if ( comps . length === 0 ) return [ ] ;
559565
560566 const L : string [ ] = [ ] ;
561- const byName : Record < string , IFunctionStatistics > = { } ;
567+ const byName : Record < string , Readonly < IFunctionStatistics > > = { } ;
562568 for ( const f of fns ) byName [ f . name ] = f ;
563569
564570 L . push ( secLine ( 'Pairwise Comparisons (paired t-test)' ) ) ;
@@ -630,8 +636,8 @@ function renderComparisons(
630636// ─── Speed matrix ────────────────────────────────────────────────────────────
631637
632638function renderMatrix (
633- fns : IFunctionStatistics [ ] ,
634- comps : IPairedComparison [ ] ,
639+ fns : readonly Readonly < IFunctionStatistics > [ ] ,
640+ comps : readonly Readonly < IPairedComparison > [ ] ,
635641) : string [ ] {
636642 // Only render for a reasonable number of functions
637643 if ( fns . length < 3 || fns . length > 8 ) return [ ] ;
@@ -713,8 +719,8 @@ function renderMatrix(
713719// ─── Measurement overhead / baseline ─────────────────────────────────────────
714720
715721function renderBaseline (
716- baseline : IFunctionStatistics | undefined ,
717- fastest : IFunctionStatistics ,
722+ baseline : Readonly < IFunctionStatistics > | undefined ,
723+ fastest : Readonly < IFunctionStatistics > ,
718724) : string [ ] {
719725 if ( ! baseline ) return [ ] ;
720726
@@ -812,7 +818,7 @@ function renderFooter(): string[] {
812818 * | Speed matrix | Developers (3-8 fns) |
813819 * | Measurement overhead | Advanced users |
814820 */
815- export function formatReport ( suite : ISuiteReport ) : string {
821+ export function formatReport ( suite : Readonly < ISuiteReport > ) : string {
816822 // ── Separate baseline from benchmarks, sort fastest → slowest ──────
817823 const baseline = suite . functions . find ( ( f ) => f . name === suite . baselineName ) ;
818824 const fns = suite . functions
@@ -851,7 +857,10 @@ export interface IReporterOptions {
851857 output ?: ( s : string ) => void ;
852858}
853859
854- function printReport ( suite : ISuiteReport , opts ?: IReporterOptions ) : void {
860+ function printReport (
861+ suite : Readonly < ISuiteReport > ,
862+ opts ?: Readonly < IReporterOptions > ,
863+ ) : void {
855864 const out =
856865 opts ?. output ??
857866 ( console . log as Exclude < IReporterOptions [ 'output' ] , undefined > ) ;
0 commit comments