Skip to content

Commit

Permalink
chore: apply automated updates
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] committed Feb 20, 2024
1 parent 95cd06e commit 8e9af22
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 35 deletions.
82 changes: 52 additions & 30 deletions test/bench.mjs
@@ -1,4 +1,4 @@
import { bench, baseline, run, group } from 'mitata'
import { bench, baseline, run, group } from "mitata";

import nodeToml from "toml";
import * as jsToml from "js-toml";
Expand All @@ -7,48 +7,70 @@ import yaml from "yaml";
import * as json5 from "json5";
import * as jsoncParser from "jsonc-parser";

import * as confbox from '../dist/index.mjs'
import * as fixtures from './fixtures.mjs'
import * as confbox from "../dist/index.mjs";
import * as fixtures from "./fixtures.mjs";

function defineBench(groupName, benchs) {
group(groupName, () => {
const _benchs = Object.entries(benchs)
const _benchs = Object.entries(benchs);
for (const [name, fn] of _benchs) {
// Warmup
for (let i = 0; i < 1000; i++) { fn() }
for (let i = 0; i < 1000; i++) {
fn();
}

const runner = name === _benchs[0][0] ? baseline : bench
runner(name, fn)
const runner = name === _benchs[0][0] ? baseline : bench;
runner(name, fn);
}
})
});
}

defineBench('yaml', {
confbox: () => { confbox.parseYaml(fixtures.yaml) },
'eemeli/yaml': () => { yaml.parse(fixtures.yaml) },
'nodeca/js-yaml': () => { jsYaml.load(fixtures.yaml) },
})
defineBench("yaml", {
confbox: () => {
confbox.parseYaml(fixtures.yaml);
},
"eemeli/yaml": () => {
yaml.parse(fixtures.yaml);
},
"nodeca/js-yaml": () => {
jsYaml.load(fixtures.yaml);
},
});

defineBench('toml', {
confbox: () => { confbox.parseToml(fixtures.toml) },
'BinaryMuse/toml-node': () => { nodeToml.parse(fixtures.toml) },
'sunnyadn/js-toml': () => { jsToml.load(fixtures.toml) },
})
defineBench("toml", {
confbox: () => {
confbox.parseToml(fixtures.toml);
},
"BinaryMuse/toml-node": () => {
nodeToml.parse(fixtures.toml);
},
"sunnyadn/js-toml": () => {
jsToml.load(fixtures.toml);
},
});

defineBench('json5', {
confbox: () => { confbox.parseJSON5(fixtures.json5) },
'json5/json5': () => { json5.default.parse(fixtures.json5) },
})
defineBench("json5", {
confbox: () => {
confbox.parseJSON5(fixtures.json5);
},
"json5/json5": () => {
json5.default.parse(fixtures.json5);
},
});

defineBench('jsonc', {
confbox: () => { confbox.parseJSONC(fixtures.jsonc) },
'microsoft/node-jsonc-parser': () => { jsoncParser.parse(fixtures.jsonc) },
})
defineBench("jsonc", {
confbox: () => {
confbox.parseJSONC(fixtures.jsonc);
},
"microsoft/node-jsonc-parser": () => {
jsoncParser.parse(fixtures.jsonc);
},
});

console.log('')
console.log("");

await run({
percentiles: false
})
percentiles: false,
});

console.log('')
console.log("");
10 changes: 5 additions & 5 deletions test/fixtures.mjs
@@ -1,17 +1,17 @@
export const yaml = /* yaml */`
export const yaml = /* yaml */ `
title: "Example"
owner:
name: "Preston-Werner"
dob: 1979-05-27T07:32:00-08:00 # dates
`.trim()
`.trim();

export const toml = /* toml */ `
title = "Example"
[owner]
name = "Preston-Werner"
dob = 1979-05-27T07:32:00-08:00 # dates
`.trim()
`.trim();

export const json5 = /* json5 */ `
{
Expand All @@ -22,7 +22,7 @@ export const json5 = /* json5 */ `
dob: '1979-05-27T07:32:00-08:00'
}
}
`.trim()
`.trim();

export const jsonc = /* jsonc */ `
{
Expand All @@ -32,4 +32,4 @@ export const jsonc = /* jsonc */ `
"dob": "1979-05-27T07:32:00-08:00" // dates
}
}
`.trim()
`.trim();

0 comments on commit 8e9af22

Please sign in to comment.