summaryrefslogtreecommitdiff
path: root/deps/node/benchmark/es/destructuring-bench.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/node/benchmark/es/destructuring-bench.js')
-rw-r--r--deps/node/benchmark/es/destructuring-bench.js50
1 files changed, 0 insertions, 50 deletions
diff --git a/deps/node/benchmark/es/destructuring-bench.js b/deps/node/benchmark/es/destructuring-bench.js
deleted file mode 100644
index 37f3fd9a..00000000
--- a/deps/node/benchmark/es/destructuring-bench.js
+++ /dev/null
@@ -1,50 +0,0 @@
-'use strict';
-
-const common = require('../common.js');
-const assert = require('assert');
-
-const bench = common.createBenchmark(main, {
- method: ['swap', 'destructure'],
- n: [1e8]
-});
-
-function runSwapManual(n) {
- var x, y, r;
- bench.start();
- for (var i = 0; i < n; i++) {
- x = 1, y = 2;
- r = x;
- x = y;
- y = r;
- assert.strictEqual(x, 2);
- assert.strictEqual(y, 1);
- }
- bench.end(n);
-}
-
-function runSwapDestructured(n) {
- var x, y;
- bench.start();
- for (var i = 0; i < n; i++) {
- x = 1, y = 2;
- [x, y] = [y, x];
- assert.strictEqual(x, 2);
- assert.strictEqual(y, 1);
- }
- bench.end(n);
-}
-
-function main({ n, method }) {
- switch (method) {
- case '':
- // Empty string falls through to next line as default, mostly for tests.
- case 'swap':
- runSwapManual(n);
- break;
- case 'destructure':
- runSwapDestructured(n);
- break;
- default:
- throw new Error(`Unexpected method "${method}"`);
- }
-}