Skip to content

Commit

Permalink
chore: update benchmark & results
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Jan 27, 2021
1 parent 25a8749 commit 10990bb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 18 deletions.
11 changes: 6 additions & 5 deletions bench/immutable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const klona = require('klona');
const assert = require('assert');
const assert = require('uvu/assert');
const { Suite } = require('benchmark');
const { klona } = require('klona/json');
const dset = require('../dist/dset');

const contenders = {
Expand All @@ -18,8 +18,8 @@ Object.keys(contenders).forEach(name => {
const input = {};
const output = contenders[name](input, 'x.y.z', 'foobar');

assert.notEqual(output, input, 'new object');
assert.deepStrictEqual(output, {
assert.is.not(output === input, 'new object');
assert.equal(output, {
x: {
y: {
z: 'foobar'
Expand All @@ -28,7 +28,7 @@ Object.keys(contenders).forEach(name => {
}, 'expected output');

input.foo = 'bar';
assert.notEqual(output.foo, 'bar', 'detached clone');
assert.is.not(output.foo, 'bar', 'detached clone');

console.log(' ✔', name);
} catch (err) {
Expand All @@ -44,6 +44,7 @@ const bench = new Suite({ onCycle });
Object.keys(contenders).forEach(name => {
bench.add(name + ' '.repeat(12 - name.length), () => {
contenders[name]({}, 'x.y.z', 'foobar');
contenders[name]({}, 'x.a.b.c', 'howdy');
});
});

Expand Down
5 changes: 3 additions & 2 deletions bench/mutable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const assert = require('assert');
const assert = require('uvu/assert');
const { Suite } = require('benchmark');

const contenders = {
Expand All @@ -13,7 +13,7 @@ Object.keys(contenders).forEach(name => {
try {
const input = {};
contenders[name](input, 'x.y.z', 'foobar');
assert.deepStrictEqual(input, {
assert.equal(input, {
x: {
y: {
z: 'foobar'
Expand All @@ -35,6 +35,7 @@ const bench = new Suite({ onCycle });
Object.keys(contenders).forEach(name => {
bench.add(name + ' '.repeat(12 - name.length), () => {
contenders[name]({}, 'x.y.z', 'foobar');
contenders[name]({}, 'x.a.b.c', 'howdy');
});
});

Expand Down
8 changes: 4 additions & 4 deletions bench/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"private": true,
"devDependencies": {
"benchmark": "2.1.4",
"clean-set": "1.1.1",
"clean-set": "1.1.2",
"deep-set": "1.0.1",
"klona": "1.1.1",
"lodash.set": "4.3.2",
"set-value": "3.0.1"
"klona": "2.0.4",
"lodash": "4.17.20",
"set-value": "3.0.2"
}
}
14 changes: 7 additions & 7 deletions bench/readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Benchmarks – Node.js

Below are the results while running this directory's suites on my machine with Node.js v10.13.0:
Below are the results while running this directory's suites on my machine with Node.js `v10.13.0`:

#### Mutable

Expand All @@ -14,10 +14,10 @@ Validation:
✔ dset
Benchmark:
deep-set x 4,130,930 ops/sec ±2.30% (92 runs sampled)
set-value x 4,905,191 ops/sec ±3.03% (91 runs sampled)
lodash/set x 2,566,991 ops/sec ±0.99% (95 runs sampled)
dset x 4,191,060 ops/sec ±0.24% (95 runs sampled)
deep-set x 1,894,926 ops/sec ±2.51% (88 runs sampled)
set-value x 2,208,207 ops/sec ±2.79% (92 runs sampled)
lodash/set x 1,271,022 ops/sec ±1.34% (90 runs sampled)
dset x 2,217,614 ops/sec ±0.55% (96 runs sampled)
```

#### Immutable
Expand All @@ -30,6 +30,6 @@ Validation:
✔ dset-klona
Benchmark:
clean-set x 5,771,347 ops/sec ±0.23% (96 runs sampled)
dset-klona x 3,726,300 ops/sec ±1.53% (93 runs sampled)
clean-set x 2,631,929 ops/sec ±2.88% (89 runs sampled)
dset-klona x 1,950,732 ops/sec ±2.11% (92 runs sampled)
```

0 comments on commit 10990bb

Please sign in to comment.