+
+
+
+
+
+ Reset suites
+
+
@@ -57,6 +74,7 @@
Copy as markdown table
+ Copy as bullet list
@@ -75,6 +93,10 @@ const suites = useStorage('benchmark-builder:suites', [
{ title: 'Suite 2', data: [8, 12] },
]);
+const unit = useStorage('benchmark-builder:unit', '');
+
+const round = (v: number) => Math.round(v * 1000) / 1000;
+
const results = computed(() => {
return suites.value
.map(({ data: dirtyData, title }) => {
@@ -88,14 +110,29 @@ const results = computed(() => {
};
})
.sort((a, b) => a.mean - b.mean)
- .map((value, index) => ({ position: index + 1, ...value }));
+ .map(({ mean, variance, ...value }, index, suites) => {
+ const cleanUnit = unit.value.trim();
+ const bestMean: number = suites[0].mean;
+ const deltaWithBestMean = mean - bestMean;
+ const ratioWithBestMean = bestMean === 0 ? '∞' : round(mean / bestMean);
+
+ const comparisonValues: string =
+ index !== 0 && bestMean !== mean ? ` (+${round(deltaWithBestMean)}${cleanUnit} ; x${ratioWithBestMean})` : '';
+
+ return {
+ position: index + 1,
+ mean: `${round(mean)}${cleanUnit}${comparisonValues}`,
+ variance: `${round(variance)}${cleanUnit}${cleanUnit ? '²' : ''}`,
+ ...value,
+ };
+ });
});
const { copy } = useClipboard();
const header = {
- title: 'Suite name',
- size: 'Sample count',
+ title: 'Suite',
+ size: 'Samples',
mean: 'Mean',
variance: 'Variance',
position: 'Position',
@@ -104,6 +141,21 @@ const header = {
function copyAsMarkdown() {
copy(arrayToMarkdownTable({ data: results.value, headerMap: header }));
}
+
+function copyAsBulletList() {
+ const bulletList = results.value
+ .flatMap(({ title, ...sections }) => {
+ return [
+ ` - ${title}`,
+ ...Object.entries(sections).map(
+ ([key, value]) => ` - ${header[key as keyof typeof header] ?? key}: ${value}`,
+ ),
+ ];
+ })
+ .join('\n');
+
+ copy(bulletList);
+}