-
Notifications
You must be signed in to change notification settings - Fork 0
/
request.js
35 lines (32 loc) · 1.17 KB
/
request.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
'use strict';
const util = require('util');
const benchmark = require('benchmark');
const dumpster = require('../');
const jss = require('json-stringify-safe');
const cjson = require('circular-json');
const sample = new (require('http').ClientRequest)();
sample.on('error', () => {});
const tinyJSONBench = new benchmark.Suite();
tinyJSONBench.add('dumpster (depth: 2)', () => {
dumpster.dump(sample, { depth: 2 });
}).add('dumpster (depth: Infinity)', () => {
dumpster.dump(sample, { depth: Infinity });
}).add('dumpster (pretty)', () => {
dumpster.dump(sample, { pretty: true, depth: Infinity });
}).add('util.inspect (depth: 2)', () => {
util.inspect(sample, { depth: 2 });
}).add('util.inspect (depth: Infinity)', () => {
util.inspect(sample, { depth: null });
}).add('json-stringify-safe', function () {
jss(sample);
}).add('json-stringify-safe (pretty)', function () {
jss(sample, null, 4);
}).add('circular-json', function () {
cjson.stringify(sample);
}).add('circular-json (pretty)', function () {
cjson.stringify(sample, null, 4);
}).on('error', e => {
console.log(e);
}).on('cycle', event => {
console.log(String(event.target));
}).run();