source: imaps-frontend/node_modules/fast-uri/benchmark.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.6 KB
Line 
1'use strict'
2
3const benchmark = require('benchmark')
4const suite = new benchmark.Suite()
5const fasturi = require('./')
6const urijs = require('uri-js')
7
8const base = 'uri://a/b/c/d;p?q'
9
10const domain = 'https://example.com/foo#bar$fiz'
11const ipv4 = '//10.10.10.10'
12const ipv6 = '//[2001:db8::7]'
13const urn = 'urn:foo:a123,456'
14const urnuuid = 'urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6'
15
16// Initialization as there is a lot to parse at first
17// eg: regexes
18fasturi.parse(domain)
19urijs.parse(domain)
20
21suite.add('fast-uri: parse domain', function () {
22 fasturi.parse(domain)
23})
24suite.add('urijs: parse domain', function () {
25 urijs.parse(domain)
26})
27suite.add('WHATWG URL: parse domain', function () {
28 // eslint-disable-next-line
29 new URL(domain)
30})
31suite.add('fast-uri: parse IPv4', function () {
32 fasturi.parse(ipv4)
33})
34suite.add('urijs: parse IPv4', function () {
35 urijs.parse(ipv4)
36})
37suite.add('fast-uri: parse IPv6', function () {
38 fasturi.parse(ipv6)
39})
40suite.add('urijs: parse IPv6', function () {
41 urijs.parse(ipv6)
42})
43suite.add('fast-uri: parse URN', function () {
44 fasturi.parse(urn)
45})
46suite.add('urijs: parse URN', function () {
47 urijs.parse(urn)
48})
49suite.add('WHATWG URL: parse URN', function () {
50 // eslint-disable-next-line
51 new URL(urn)
52})
53suite.add('fast-uri: parse URN uuid', function () {
54 fasturi.parse(urnuuid)
55})
56suite.add('urijs: parse URN uuid', function () {
57 urijs.parse(urnuuid)
58})
59suite.add('fast-uri: serialize uri', function () {
60 fasturi.serialize({
61 scheme: 'uri',
62 userinfo: 'foo:bar',
63 host: 'example.com',
64 port: 1,
65 path: 'path',
66 query: 'query',
67 fragment: 'fragment'
68 })
69})
70suite.add('urijs: serialize uri', function () {
71 urijs.serialize({
72 scheme: 'uri',
73 userinfo: 'foo:bar',
74 host: 'example.com',
75 port: 1,
76 path: 'path',
77 query: 'query',
78 fragment: 'fragment'
79 })
80})
81suite.add('fast-uri: serialize IPv6', function () {
82 fasturi.serialize({ host: '2606:2800:220:1:248:1893:25c8:1946' })
83})
84suite.add('urijs: serialize IPv6', function () {
85 urijs.serialize({ host: '2606:2800:220:1:248:1893:25c8:1946' })
86})
87suite.add('fast-uri: serialize ws', function () {
88 fasturi.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar', secure: true })
89})
90suite.add('urijs: serialize ws', function () {
91 urijs.serialize({ scheme: 'ws', host: 'example.com', resourceName: '/foo?bar', secure: true })
92})
93suite.add('fast-uri: resolve', function () {
94 fasturi.resolve(base, '../../../g')
95})
96suite.add('urijs: resolve', function () {
97 urijs.resolve(base, '../../../g')
98})
99suite.on('cycle', cycle)
100
101suite.run()
102
103function cycle (e) {
104 console.log(e.target.toString())
105}
Note: See TracBrowser for help on using the repository browser.