Skip to content

Commit c1087d6

Browse files
authored
chore: Update benchmark code (#730)
- There's no need to let Resvg to load system fonts as Satori embeds all text into paths. This saves us quite a lot. - Use lower compression level for Sharp to align better with Resvg (which doesn't do much compression).
1 parent 4e761c6 commit c1087d6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/benchmark/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,13 +257,18 @@ function generatePNGWithResvg(svg: string) {
257257
mode: 'width',
258258
value: 1200,
259259
},
260+
font: {
261+
loadSystemFonts: false,
262+
fontFiles: [],
263+
fontDirs: [],
264+
},
260265
})
261266
const pngData = resvg.render()
262267
return pngData.asPng()
263268
}
264269

265270
async function generatePNGWithSharp(svg: string) {
266-
await Sharp(Buffer.from(svg)).png().toBuffer()
271+
await Sharp(Buffer.from(svg)).png({ compressionLevel: 2 }).toBuffer()
267272
}
268273

269274
summary(() => {

0 commit comments

Comments
 (0)