Skip to content

Commit aa93f74

Browse files
committed
chore: remove bench-related dependencies
Also disable skr-canvas in the bench
1 parent b3b30d0 commit aa93f74

File tree

4 files changed

+73
-639
lines changed

4 files changed

+73
-639
lines changed

README.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<a href="https://github.com/yisibl/resvg-js/actions"><img alt="GitHub CI Status" src="https://github.com/yisibl/resvg-js/workflows/CI/badge.svg?branch=main"></a>
44
<a href="https://www.npmjs.com/package/@resvg/resvg-js"><img src="https://img.shields.io/npm/v/@resvg/resvg-js.svg?sanitize=true" alt="@resvg/resvg-js npm version"></a>
55
<a href="https://npmcharts.com/compare/@resvg/resvg-js?minimal=true"><img src="https://img.shields.io/npm/dm/@resvg/resvg-js.svg?sanitize=true" alt="@resvg/resvg-js downloads"></a>
6+
[![Rust 1.65+](https://img.shields.io/badge/rust-1.65+-orange.svg)](https://www.rust-lang.org)
67

78
> resvg-js is a high-performance SVG renderer and toolkit, powered by Rust based [resvg](https://github.com/RazrFalcon/resvg/), with Node.js backend using [napi-rs](https://github.com/napi-rs/napi-rs), also a pure WebAssmebly backend.
89
@@ -166,6 +167,11 @@ See [playground](wasm/index.html), it is also possible to [call Wasm in Node.js]
166167
167168
## Sample Benchmark
168169
170+
```shell
171+
npm i benny@3.x sharp@0.x @types/sharp svg2img@0.x
172+
npm run bench
173+
```
174+
169175
```shell
170176
Running "resize width" suite...
171177
resvg-js(Rust):

benchmark/bench.ts

+46-46
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { promises as fs } from 'fs'
22
import { join } from 'path'
33

4-
import { createCanvas, Image } from '@napi-rs/canvas'
4+
// import { createCanvas, Image } from '@napi-rs/canvas'
55
import b from 'benny'
66
import sharp from 'sharp'
77
import svg2img from 'svg2img'
@@ -37,25 +37,25 @@ async function run() {
3737
}),
3838

3939
// test from https://github.com/Brooooooklyn/canvas/blob/main/example/resize-svg.js
40-
b.add('skr-canvas(Rust)', () => {
41-
const image = new Image()
42-
image.src = svg1
40+
// b.add('skr-canvas(Rust)', () => {
41+
// const image = new Image()
42+
// image.src = svg1
4343

44-
const w = 1200
45-
const h = 623
44+
// const w = 1200
45+
// const h = 623
4646

47-
// resize SVG
48-
image.width = w
49-
image.height = h
47+
// // resize SVG
48+
// image.width = w
49+
// image.height = h
5050

51-
// create a canvas of the same size as the image
52-
const canvas = createCanvas(w, h)
53-
const ctx = canvas.getContext('2d')
51+
// // create a canvas of the same size as the image
52+
// const canvas = createCanvas(w, h)
53+
// const ctx = canvas.getContext('2d')
5454

55-
// fill the canvas with the image
56-
ctx.drawImage(image, 0, 0)
57-
canvas.toBuffer('image/png')
58-
}),
55+
// // fill the canvas with the image
56+
// ctx.drawImage(image, 0, 0)
57+
// canvas.toBuffer('image/png')
58+
// }),
5959

6060
b.add('svg2img(canvg + node-canvas)', () => {
6161
svg2img(svg1.toString('utf8'), { width: 1200, height: 623 }, function (_error, _buffer) {})
@@ -93,25 +93,25 @@ async function run() {
9393
}),
9494

9595
// test from https://github.com/Brooooooklyn/canvas/blob/main/example/resize-svg.js
96-
b.add('skr-canvas(Rust)', () => {
97-
const image = new Image()
98-
image.src = icon
96+
// b.add('skr-canvas(Rust)', () => {
97+
// const image = new Image()
98+
// image.src = icon
9999

100-
const w = 386
101-
const h = 386
100+
// const w = 386
101+
// const h = 386
102102

103-
// resize SVG
104-
image.width = w
105-
image.height = h
103+
// // resize SVG
104+
// image.width = w
105+
// image.height = h
106106

107-
// create a canvas of the same size as the image
108-
const canvas = createCanvas(w, h)
109-
const ctx = canvas.getContext('2d')
107+
// // create a canvas of the same size as the image
108+
// const canvas = createCanvas(w, h)
109+
// const ctx = canvas.getContext('2d')
110110

111-
// fill the canvas with the image
112-
ctx.drawImage(image, 0, 0)
113-
canvas.toBuffer('image/png')
114-
}),
111+
// // fill the canvas with the image
112+
// ctx.drawImage(image, 0, 0)
113+
// canvas.toBuffer('image/png')
114+
// }),
115115

116116
b.add('svg2img(canvg + node-canvas)', () => {
117117
svg2img(icon.toString('utf8'), { width: 386, height: 386 }, function (_error, _buffer) {})
@@ -139,25 +139,25 @@ async function run() {
139139
await sharp(tiger).toBuffer()
140140
}),
141141

142-
b.add('skr-canvas(Rust)', () => {
143-
const image = new Image()
144-
image.src = tiger
142+
// b.add('skr-canvas(Rust)', () => {
143+
// const image = new Image()
144+
// image.src = tiger
145145

146-
const w = 900
147-
const h = 900
146+
// const w = 900
147+
// const h = 900
148148

149-
// resize SVG
150-
image.width = w
151-
image.height = h
149+
// // resize SVG
150+
// image.width = w
151+
// image.height = h
152152

153-
// create a canvas of the same size as the image
154-
const canvas = createCanvas(w, h)
155-
const ctx = canvas.getContext('2d')
153+
// // create a canvas of the same size as the image
154+
// const canvas = createCanvas(w, h)
155+
// const ctx = canvas.getContext('2d')
156156

157-
// fill the canvas with the image
158-
ctx.drawImage(image, 0, 0)
159-
canvas.toBuffer('image/png')
160-
}),
157+
// // fill the canvas with the image
158+
// ctx.drawImage(image, 0, 0)
159+
// canvas.toBuffer('image/png')
160+
// }),
161161

162162
b.add('svg2img(canvg + node-canvas)', () => {
163163
svg2img(tiger.toString('utf8'), { width: 900, height: 900 }, function (_error, _buffer) {})

package.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,12 @@
7373
"version": "napi version"
7474
},
7575
"devDependencies": {
76-
"@napi-rs/canvas": "^0.1.25",
77-
"@napi-rs/cli": "^2.14.5",
76+
"@napi-rs/cli": "^2.14.6",
7877
"@swc-node/register": "^1.5.1",
7978
"@types/node": "^18.0.0",
80-
"@types/sharp": "^0.31.0",
8179
"@typescript-eslint/eslint-plugin": "^5.30.3",
8280
"@typescript-eslint/parser": "^5.30.3",
8381
"ava": "^5.0.0",
84-
"benny": "^3.7.1",
8582
"copyfiles": "^2.4.1",
8683
"dts-bundle-generator": "^6.12.0",
8784
"esbuild": "^0.17.0",
@@ -96,7 +93,6 @@
9693
"node-fetch": "2.x",
9794
"npm-run-all": "^4.1.5",
9895
"prettier": "^2.7.1",
99-
"sharp": "^0.31.0",
10096
"typescript": "^4.7.4"
10197
},
10298
"lint-staged": {

0 commit comments

Comments
 (0)