main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
740 bytes
|
Rev | Line | |
---|
[d565449] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | const Benchmark = require('benchmark');
|
---|
| 4 | const suite = new Benchmark.Suite;
|
---|
| 5 | const testData = require('./test.json');
|
---|
| 6 |
|
---|
| 7 |
|
---|
| 8 | const stringifyPackages = {
|
---|
| 9 | // 'JSON.stringify': JSON.stringify,
|
---|
| 10 | 'fast-json-stable-stringify': require('../index'),
|
---|
| 11 | 'json-stable-stringify': true,
|
---|
| 12 | 'fast-stable-stringify': true,
|
---|
| 13 | 'faster-stable-stringify': true
|
---|
| 14 | };
|
---|
| 15 |
|
---|
| 16 |
|
---|
| 17 | for (const name in stringifyPackages) {
|
---|
| 18 | let func = stringifyPackages[name];
|
---|
| 19 | if (func === true) func = require(name);
|
---|
| 20 |
|
---|
| 21 | suite.add(name, function() {
|
---|
| 22 | func(testData);
|
---|
| 23 | });
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | suite
|
---|
| 27 | .on('cycle', (event) => console.log(String(event.target)))
|
---|
| 28 | .on('complete', function () {
|
---|
| 29 | console.log('The fastest is ' + this.filter('fastest').map('name'));
|
---|
| 30 | })
|
---|
| 31 | .run({async: true});
|
---|
Note:
See
TracBrowser
for help on using the repository browser.