@@ -8,6 +8,14 @@ function formatDeltaMs(value: number) {
88 return `${ sign } ${ value . toFixed ( 2 ) } ms`
99}
1010
11+ function formatBytes ( value : number ) {
12+ if ( value >= 1024 ) {
13+ return `${ ( value / 1024 ) . toFixed ( 2 ) } KB`
14+ }
15+
16+ return `${ value } B`
17+ }
18+
1119function formatMemory ( value : number ) {
1220 const sign = value > 0 ? '+' : ''
1321 const absolute = Math . abs ( value )
@@ -23,6 +31,11 @@ function formatPercent(value: number) {
2331 return `${ value . toFixed ( 1 ) } %`
2432}
2533
34+ function formatByteDelta ( value : number ) {
35+ const sign = value > 0 ? '+' : ''
36+ return `${ sign } ${ formatBytes ( value ) } `
37+ }
38+
2639function getDeltaClass ( value : number ) {
2740 if ( value < 0 ) {
2841 return styles . positive
@@ -33,6 +46,64 @@ function getDeltaClass(value: number) {
3346 return styles . muted
3447}
3548
49+ const bundleSizeRows = [
50+ {
51+ artifact : 'react-tooltip.min.mjs' ,
52+ v5Raw : 22704 ,
53+ v6Raw : 20749 ,
54+ rawDelta : - 1955 ,
55+ rawDeltaPercent : - 8.6 ,
56+ v5Gzip : 7670 ,
57+ v6Gzip : 7192 ,
58+ gzipDelta : - 478 ,
59+ gzipDeltaPercent : - 6.2 ,
60+ } ,
61+ {
62+ artifact : 'react-tooltip.min.cjs' ,
63+ v5Raw : 23414 ,
64+ v6Raw : 21067 ,
65+ rawDelta : - 2347 ,
66+ rawDeltaPercent : - 10.0 ,
67+ v5Gzip : 7733 ,
68+ v6Gzip : 7167 ,
69+ gzipDelta : - 566 ,
70+ gzipDeltaPercent : - 7.3 ,
71+ } ,
72+ {
73+ artifact : 'react-tooltip.umd.min.js' ,
74+ v5Raw : 23691 ,
75+ v6Raw : 21357 ,
76+ rawDelta : - 2334 ,
77+ rawDeltaPercent : - 9.9 ,
78+ v5Gzip : 7824 ,
79+ v6Gzip : 7259 ,
80+ gzipDelta : - 565 ,
81+ gzipDeltaPercent : - 7.2 ,
82+ } ,
83+ {
84+ artifact : 'react-tooltip.min.css' ,
85+ v5Raw : 2129 ,
86+ v6Raw : 2129 ,
87+ rawDelta : 0 ,
88+ rawDeltaPercent : 0 ,
89+ v5Gzip : 706 ,
90+ v6Gzip : 706 ,
91+ gzipDelta : 0 ,
92+ gzipDeltaPercent : 0 ,
93+ } ,
94+ ]
95+
96+ const packageSizeSnapshot = {
97+ v5Tarball : 212464 ,
98+ v6Tarball : 114179 ,
99+ tarballDelta : - 98285 ,
100+ tarballDeltaPercent : - 46.3 ,
101+ v5Unpacked : 894316 ,
102+ v6Unpacked : 483478 ,
103+ unpackedDelta : - 410838 ,
104+ unpackedDeltaPercent : - 45.9 ,
105+ }
106+
36107export default function BenchmarkPage ( ) : React . JSX . Element {
37108 const largestRow = benchmarkSnapshot . rows [ benchmarkSnapshot . rows . length - 1 ]
38109 const strongestMountWin = benchmarkSnapshot . rows . reduce ( ( best , row ) =>
@@ -282,6 +353,54 @@ export default function BenchmarkPage(): React.JSX.Element {
282353 consequential.
283354 </ p >
284355 </ div >
356+ < div className = { styles . cardBody } >
357+ < h3 className = { styles . cardTitle } > Shipped Size</ h3 >
358+ < p className = { styles . cardText } style = { { marginBottom : '1rem' } } >
359+ Runtime bundle size was also reduced. The minified JavaScript artifacts shipped by
360+ v6 are smaller than their v5 equivalents across ESM, CJS, and UMD, while the
361+ published CSS stays unchanged.
362+ </ p >
363+ < div className = { styles . tableWrap } >
364+ < table className = { `${ styles . table } ${ styles . compactTable } ` } >
365+ < thead >
366+ < tr >
367+ < th className = { styles . countColumn } > Artifact</ th >
368+ < th className = { styles . mountGroup } > V5 Raw</ th >
369+ < th className = { styles . mountGroup } > V6 Raw</ th >
370+ < th className = { styles . mountGroup } > Raw Delta</ th >
371+ < th className = { styles . mountGroup } > V5 Gzip</ th >
372+ < th className = { styles . mountGroup } > V6 Gzip</ th >
373+ < th className = { styles . mountGroup } > Gzip Delta</ th >
374+ </ tr >
375+ </ thead >
376+ < tbody >
377+ { bundleSizeRows . map ( ( row ) => (
378+ < tr key = { row . artifact } >
379+ < td className = { styles . countCell } > { row . artifact } </ td >
380+ < td className = { styles . metricCell } > { formatBytes ( row . v5Raw ) } </ td >
381+ < td className = { styles . metricCell } > { formatBytes ( row . v6Raw ) } </ td >
382+ < td className = { `${ styles . metricCell } ${ getDeltaClass ( row . rawDelta ) } ` } >
383+ { formatByteDelta ( row . rawDelta ) } ({ formatPercent ( row . rawDeltaPercent ) } )
384+ </ td >
385+ < td className = { styles . metricCell } > { formatBytes ( row . v5Gzip ) } </ td >
386+ < td className = { styles . metricCell } > { formatBytes ( row . v6Gzip ) } </ td >
387+ < td className = { `${ styles . metricCell } ${ getDeltaClass ( row . gzipDelta ) } ` } >
388+ { formatByteDelta ( row . gzipDelta ) } ({ formatPercent ( row . gzipDeltaPercent ) } )
389+ </ td >
390+ </ tr >
391+ ) ) }
392+ </ tbody >
393+ </ table >
394+ </ div >
395+ < p className = { styles . cardText } >
396+ These numbers were measured from the built < b > dist/</ b > artifacts and the packed
397+ npm package for each version, so they reflect shipped output rather than source
398+ size.
399+ </ p >
400+ < p className = { styles . cardText } >
401+ If you like the project, please give the project a GitHub 🌟
402+ </ p >
403+ </ div >
285404 </ section >
286405 </ div >
287406 </ div >
0 commit comments