Skip to content

Commit

Permalink
fixed DataView clone algorithm + added new benchmark test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuriy-Khomenko committed Oct 1, 2020
1 parent 6707e4f commit 01a9325
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 3 deletions.
53 changes: 51 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## qclone
the fastest function for deep clone js objects compatible with es6
the fastest function for deep clone js objects compatible with es6

### Install

Expand All @@ -8,7 +8,7 @@ npm install --save qclone
### Usage

const { qclone } = require('qclone');

or connect separate modules:

const qclone = require('qclone/src/qcloneStrictCircular');
Expand All @@ -23,6 +23,7 @@ const newCloneObj = qclone( { foo: 1 } );
- very quickly clone(qclone);
- correctly clone(qcloneStrict / qcloneStrictCircular);
- support circular objects(qcloneCircular / qcloneStrictCircular);
- library has no dependencies;

For more than 90% of cases, the algorithm is suitable - qclone.
If you lack it, for example, for cyclic objects or strict copying, you can use the following algorithms:
Expand Down Expand Up @@ -71,6 +72,54 @@ benchRfdcCirclesProto*100: 5541.977ms
| fast-clone | 125.238 |
| qcloneStrict | 121.703 |

```
Nodejs - v14.9.0
Date - 01.10.2020
```

[klona](https://github.com/lukeed/klona) project test result

```
Benchmark :: json
JSON.stringify x 18,355 ops/sec ±0.68% (83 runs sampled)
lodash x 19,501 ops/sec ±0.53% (87 runs sampled)
rfdc x 90,519 ops/sec ±0.57% (88 runs sampled)
clone x 16,963 ops/sec ±0.33% (88 runs sampled)
clone/include x 9,343 ops/sec ±0.70% (90 runs sampled)
clone-deep x 52,055 ops/sec ±0.79% (89 runs sampled)
deep-copy x 51,496 ops/sec ±0.22% (87 runs sampled)
klona/full x 21,732 ops/sec ±0.24% (92 runs sampled)
klona x 114,363 ops/sec ±0.57% (89 runs sampled)
klona/lite x 127,689 ops/sec ±0.57% (88 runs sampled)
klona/json x 136,417 ops/sec ±0.23% (92 runs sampled)
qclone x 141,203 ops/sec ±0.41% (90 runs sampled)
Benchmark :: lite
lodash x 14,211 ops/sec ±0.36% (92 runs sampled)
clone x 14,738 ops/sec ±1.38% (87 runs sampled)
clone/include x 7,970 ops/sec ±0.67% (89 runs sampled)
clone-deep x 41,739 ops/sec ±0.47% (90 runs sampled)
klona/full x 18,371 ops/sec ±0.34% (89 runs sampled)
klona x 89,160 ops/sec ±0.42% (91 runs sampled)
klona/lite x 97,288 ops/sec ±0.65% (90 runs sampled)
qclone x 109,539 ops/sec ±0.27% (90 runs sampled)
*The next two tests below clone the keys for the Map class if those are objects. I do not consider this behavior to be correct, since the work for such keys is based on references and not values (most cloning libraries support my opinion).
Benchmark :: default
lodash x 14,529 ops/sec ±2.64% (82 runs sampled)
clone x 31,979 ops/sec ±0.35% (88 runs sampled)
clone/include x 18,751 ops/sec ±0.50% (87 runs sampled)
klona/full x 30,788 ops/sec ±1.00% (88 runs sampled)
klona x 77,617 ops/sec ±0.34% (91 runs sampled)
qclone x 169,658 ops/sec ±0.59% (90 runs sampled)
Benchmark :: full
lodash x 15,970 ops/sec ±0.59% (89 runs sampled)
clone/include x 12,483 ops/sec ±3.87% (82 runs sampled)
klona/full x 26,556 ops/sec ±1.47% (88 runs sampled)
qclone x 260,155 ops/sec ±0.63% (91 runs sampled)
```

### License

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "qclone",
"version": "1.0.4",
"version": "1.0.5",
"description": "the fastest function for deep clone js objects compatible with es6",
"main": "src/index.js",
"scripts": {
Expand Down

0 comments on commit 01a9325

Please sign in to comment.