Skip to content

Commit 58ad918

Browse files
authored
Update public suffix (#82)
* Update publicsuffix lists * Move benchmark in its own repository
1 parent eb7e003 commit 58ad918

9 files changed

+936
-1212
lines changed

CHANGELOG.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
### Not Released
44

5+
### 4.0.3
6+
7+
*2019-03-10*
8+
9+
- [#82](https://github.com/remusao/tldts/pull/82) Update Public Suffix Lists
10+
511
### 4.0.2
612

713
*2019-02-05*
814

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

1217
### 4.0.1
1318

bench/Makefile

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
all: run
3+
4+
requests.json:
5+
curl https://cdn.cliqz.com/adblocking/requests_top500.json.gz | gunzip > requests.json
6+
7+
run: requests.json
8+
NODE_ENV=production node benchmark.js

bench/benchmark.js

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env node
2+
3+
const { URL } = require('url');
4+
const fs = require('fs');
5+
const path = require('path');
6+
7+
const tldtsExperimental = require(path.resolve(
8+
__dirname,
9+
'../dist/tldts-experimental.umd.min.js',
10+
));
11+
const tldtsDefault = require(path.resolve(
12+
__dirname,
13+
'../dist/tldts.umd.min.js',
14+
));
15+
16+
function bench(title, tldts, inputs) {
17+
console.log(`* Start: ${title}`);
18+
const t0 = Date.now();
19+
for (let i = 0; i < inputs.length; i += 1) {
20+
tldts.parse(inputs[i]);
21+
tldts.parse(inputs[i]);
22+
tldts.parse(inputs[i]);
23+
tldts.parse(inputs[i]);
24+
tldts.parse(inputs[i]);
25+
}
26+
const total = Date.now() - t0;
27+
console.log(` - ${total / 5} ms`);
28+
console.log(` - ${total / inputs.length / 5} ms per input`);
29+
console.log(
30+
` - ${Math.floor(1000 / (total / inputs.length / 5))} calls per second`,
31+
);
32+
}
33+
34+
function main() {
35+
const urls = [
36+
...new Set(
37+
fs
38+
.readFileSync(path.resolve(__dirname, './requests.json'), {
39+
encoding: 'utf-8',
40+
})
41+
.split(/[\n\r]+/g)
42+
.map(JSON.parse)
43+
.map(({ url }) => url),
44+
),
45+
];
46+
console.log('urls', urls.length);
47+
48+
const hostnames = [...new Set(urls.map(url => new URL(url).hostname))];
49+
console.log('Hosts', hostnames.length);
50+
51+
bench('tldts URLs', tldtsDefault, urls);
52+
bench('tldts-experimental URLs', tldtsExperimental, urls);
53+
bench('tldts hostnames', tldtsDefault, hostnames);
54+
bench('tldts-experimental hostnames', tldtsExperimental, hostnames);
55+
}
56+
57+
main();

bin/benchmark.js

-115
This file was deleted.

lib/lookup/data/trie.ts

+1-1
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)