Skip to content

Commit

Permalink
Update public suffix (#82)
Browse files Browse the repository at this point in the history
* Update publicsuffix lists
* Move benchmark in its own repository
  • Loading branch information
remusao authored Mar 10, 2019
1 parent eb7e003 commit 58ad918
Show file tree
Hide file tree
Showing 9 changed files with 936 additions and 1,212 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,17 @@

### Not Released

### 4.0.3

*2019-03-10*

- [#82](https://github.com/remusao/tldts/pull/82) Update Public Suffix Lists

### 4.0.2

*2019-02-05*

- [#36](https://github.com/remusao/tldts/pull/36) Update Public Suffix Lists
*

### 4.0.1

Expand Down
8 changes: 8 additions & 0 deletions bench/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

all: run

requests.json:
curl https://cdn.cliqz.com/adblocking/requests_top500.json.gz | gunzip > requests.json

run: requests.json
NODE_ENV=production node benchmark.js
57 changes: 57 additions & 0 deletions bench/benchmark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/usr/bin/env node

const { URL } = require('url');
const fs = require('fs');
const path = require('path');

const tldtsExperimental = require(path.resolve(
__dirname,
'../dist/tldts-experimental.umd.min.js',
));
const tldtsDefault = require(path.resolve(
__dirname,
'../dist/tldts.umd.min.js',
));

function bench(title, tldts, inputs) {
console.log(`* Start: ${title}`);
const t0 = Date.now();
for (let i = 0; i < inputs.length; i += 1) {
tldts.parse(inputs[i]);
tldts.parse(inputs[i]);
tldts.parse(inputs[i]);
tldts.parse(inputs[i]);
tldts.parse(inputs[i]);
}
const total = Date.now() - t0;
console.log(` - ${total / 5} ms`);
console.log(` - ${total / inputs.length / 5} ms per input`);
console.log(
` - ${Math.floor(1000 / (total / inputs.length / 5))} calls per second`,
);
}

function main() {
const urls = [
...new Set(
fs
.readFileSync(path.resolve(__dirname, './requests.json'), {
encoding: 'utf-8',
})
.split(/[\n\r]+/g)
.map(JSON.parse)
.map(({ url }) => url),
),
];
console.log('urls', urls.length);

const hostnames = [...new Set(urls.map(url => new URL(url).hostname))];
console.log('Hosts', hostnames.length);

bench('tldts URLs', tldtsDefault, urls);
bench('tldts-experimental URLs', tldtsExperimental, urls);
bench('tldts hostnames', tldtsDefault, hostnames);
bench('tldts-experimental hostnames', tldtsExperimental, hostnames);
}

main();
115 changes: 0 additions & 115 deletions bin/benchmark.js

This file was deleted.

2 changes: 1 addition & 1 deletion lib/lookup/data/trie.ts

Large diffs are not rendered by default.

Loading

0 comments on commit 58ad918

Please sign in to comment.