Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove encodeurl #23

Merged
merged 1 commit into from
Jan 14, 2023
Merged

remove encodeurl #23

merged 1 commit into from
Jan 14, 2023

Conversation

Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Jan 14, 2023

Native encodeURI ist faster than the package encodeurl. So ripping it out....

'use strict'

const benchmark = require('benchmark')
const encodeurl = require('encodeurl')

const url = 'http://localhost/%20snow.html'
const encoded = '/\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x0a\x0b\x0c\x0d\x0e\x0f'

new benchmark.Suite()
  .add('encodeurl', function () { encodeurl(url) }, { minSamples: 100 })
  .add('encodeurl', function () { encodeurl(encoded) }, { minSamples: 100 })
  .add('encodeURI', function () { encodeURI(url) }, { minSamples: 100 })
  .add('encodeURI', function () { encodeURI(encoded) }, { minSamples: 100 })

  .on('cycle', function onCycle(event) { console.log(String(event.target)) })
  .run({ async: false })
node benchmarks/encodeUrl.js
encodeurl x 3,459,417 ops/sec ±0.58% (186 runs sampled)
encodeurl x 1,325,988 ops/sec ±0.48% (187 runs sampled)
encodeURI x 5,864,314 ops/sec ±0.12% (194 runs sampled)
encodeURI x 5,904,443 ops/sec ±3.06% (187 runs sampled)

Checklist

@Uzlopak Uzlopak requested a review from mcollina January 14, 2023 15:20
@Uzlopak Uzlopak merged commit 5e28adc into master Jan 14, 2023
@Uzlopak Uzlopak deleted the remove-encodeurl branch January 14, 2023 15:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants