Skip to content

Commit

Permalink
chore: update the benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarneo committed Aug 5, 2023
1 parent 62e6e7e commit 8bef8e6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 15 deletions.
17 changes: 3 additions & 14 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
const bench = require('nanobench');
const extractDomainDist = require('./dist/extract-domain');
const extractDomain = require('../index');
import bench from 'nanobench';
import extractDomain from '../dist/extract-domain.module.js';
const url = 'https://www.npmjs.com/package/extract-domain';

const times = 10000;
const times = 100000;

const timesToLocale = times.toLocaleString();

Expand All @@ -28,16 +27,6 @@ function extractDomainRegEx(url) {
bench(`extract domain dist ${timesToLocale} times`, (b) => {
b.start();

for (let i = 0; i < times; i++) {
extractDomainDist(url) === 'npmjs.com';
}

b.end();
});

bench(`extract domain ${timesToLocale} times`, (b) => {
b.start();

for (let i = 0; i < times; i++) {
extractDomain(url) === 'npmjs.com';
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"build": "npm run pretty && microbundle -i extractDomain -f modern,esm,cjs --external psl index.ts",
"test": "mocha -R spec tests/",
"pretty": "prettier --tab-width=4 --print-width=100 --single-quote --trailing-comma=es5 --write *.ts *.ts",
"benchmark": "node benchmark.js"
"benchmark": "node benchmark/benchmark.js"
},
"repository": {
"type": "git",
Expand Down

0 comments on commit 8bef8e6

Please sign in to comment.