| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -235,12 +235,3 @@ it returns to accomplish what they need. This function reports timing | |||
| 235 | 235 | data to the parent process (usually created by running `compare.js`, `run.js` or | |
| 236 | 236 | `scatter.js`). | |
| 237 | 237 | ||
| 238 | - ### v8ForceOptimization(method[, ...args]) | ||
| 239 | - | ||
| 240 | - Force V8 to mark the `method` for optimization with the native function | ||
| 241 | - `%OptimizeFunctionOnNextCall()` and return the optimization status | ||
| 242 | - after that. | ||
| 243 | - | ||
| 244 | - It can be used to prevent the benchmark from getting disrupted by the optimizer | ||
| 245 | - kicking in halfway through. However, this could result in a less effective | ||
| 246 | - optimization. In general, only use it if you know what it actually does. | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common.js'); | |
| 3 | - const v8 = require('v8'); | ||
| 4 | 3 | ||
| 5 | 4 | const bench = common.createBenchmark(main, { | |
| 6 | 5 | size: [16, 512, 1024, 4096, 16386], | |
@@ -20,7 +19,6 @@ function main(conf) { | |||
| 20 | 19 | ||
| 21 | 20 | b1[size - 1] = 'b'.charCodeAt(0); | |
| 22 | 21 | ||
| 23 | - // Force optimization before starting the benchmark | ||
| 24 | 22 | switch (args) { | |
| 25 | 23 | case 2: | |
| 26 | 24 | b0.compare(b1, 0); | |
@@ -37,8 +35,6 @@ function main(conf) { | |||
| 37 | 35 | default: | |
| 38 | 36 | b0.compare(b1); | |
| 39 | 37 | } | |
| 40 | - v8.setFlagsFromString('--allow_natives_syntax'); | ||
| 41 | - eval('%OptimizeFunctionOnNextCall(b0.compare)'); | ||
| 42 | 38 | switch (args) { | |
| 43 | 39 | case 2: | |
| 44 | 40 | b0.compare(b1, 0); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,5 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | const common = require('../common.js'); | |
| 3 | - const v8 = require('v8'); | ||
| 4 | 3 | ||
| 5 | 4 | const bench = common.createBenchmark(main, { | |
| 6 | 5 | method: ['offset', 'slice'], | |
@@ -9,18 +8,6 @@ const bench = common.createBenchmark(main, { | |||
| 9 | 8 | }); | |
| 10 | 9 | ||
| 11 | 10 | function compareUsingSlice(b0, b1, len, iter) { | |
| 12 | - | ||
| 13 | - // Force optimization before starting the benchmark | ||
| 14 | - Buffer.compare(b0.slice(1, len), b1.slice(1, len)); | ||
| 15 | - v8.setFlagsFromString('--allow_natives_syntax'); | ||
| 16 | - eval('%OptimizeFunctionOnNextCall(Buffer.compare)'); | ||
| 17 | - eval('%OptimizeFunctionOnNextCall(b0.slice)'); | ||
| 18 | - eval('%OptimizeFunctionOnNextCall(b1.slice)'); | ||
| 19 | - Buffer.compare(b0.slice(1, len), b1.slice(1, len)); | ||
| 20 | - doCompareUsingSlice(b0, b1, len, iter); | ||
| 21 | - } | ||
| 22 | - | ||
| 23 | - function doCompareUsingSlice(b0, b1, len, iter) { | ||
| 24 | 11 | var i; | |
| 25 | 12 | bench.start(); | |
| 26 | 13 | for (i = 0; i < iter; i++) | |
@@ -29,16 +16,6 @@ function doCompareUsingSlice(b0, b1, len, iter) { | |||
| 29 | 16 | } | |
| 30 | 17 | ||
| 31 | 18 | function compareUsingOffset(b0, b1, len, iter) { | |
| 32 | - len = len + 1; | ||
| 33 | - // Force optimization before starting the benchmark | ||
| 34 | - b0.compare(b1, 1, len, 1, len); | ||
| 35 | - v8.setFlagsFromString('--allow_natives_syntax'); | ||
| 36 | - eval('%OptimizeFunctionOnNextCall(b0.compare)'); | ||
| 37 | - b0.compare(b1, 1, len, 1, len); | ||
| 38 | - doCompareUsingOffset(b0, b1, len, iter); | ||
| 39 | - } | ||
| 40 | - | ||
| 41 | - function doCompareUsingOffset(b0, b1, len, iter) { | ||
| 42 | 19 | var i; | |
| 43 | 20 | bench.start(); | |
| 44 | 21 | for (i = 0; i < iter; i++) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,6 @@ | |||
| 1 | 1 | 'use strict'; | |
| 2 | 2 | ||
| 3 | 3 | const common = require('../common.js'); | |
| 4 | - const v8 = require('v8'); | ||
| 5 | 4 | ||
| 6 | 5 | const bench = common.createBenchmark(main, { | |
| 7 | 6 | aligned: ['true', 'false'], | |
@@ -81,9 +80,7 @@ function main(conf) { | |||
| 81 | 80 | const buf = createBuffer(len, aligned === 'true'); | |
| 82 | 81 | const bufferSwap = genMethod(method); | |
| 83 | 82 | ||
| 84 | - v8.setFlagsFromString('--allow_natives_syntax'); | ||
| 85 | - eval('%OptimizeFunctionOnNextCall(bufferSwap)'); | ||
| 86 | - | ||
| 83 | + bufferSwap(n, buf); | ||
| 87 | 84 | bench.start(); | |
| 88 | 85 | bufferSwap(n, buf); | |
| 89 | 86 | bench.end(n); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -229,17 +229,3 @@ Benchmark.prototype.report = function(rate, elapsed) { | |||
| 229 | 229 | type: 'report' | |
| 230 | 230 | }); | |
| 231 | 231 | }; | |
| 232 | - | ||
| 233 | - exports.v8ForceOptimization = function(method) { | ||
| 234 | - if (typeof method !== 'function') | ||
| 235 | - return; | ||
| 236 | - | ||
| 237 | - const v8 = require('v8'); | ||
| 238 | - v8.setFlagsFromString('--allow_natives_syntax'); | ||
| 239 | - | ||
| 240 | - const args = Array.prototype.slice.call(arguments, 1); | ||
| 241 | - method.apply(null, args); | ||
| 242 | - eval('%OptimizeFunctionOnNextCall(method)'); | ||
| 243 | - method.apply(null, args); | ||
| 244 | - return eval('%GetOptimizationStatus(method)'); | ||
| 245 | - }; | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -12,9 +12,12 @@ function main(conf) { | |||
| 12 | 12 | const v = conf.v; | |
| 13 | 13 | const method = require(v).getCiphers; | |
| 14 | 14 | var i = 0; | |
| 15 | - | ||
| 16 | - common.v8ForceOptimization(method); | ||
| 15 | + // first call to getChipers will dominate the results | ||
| 16 | + if (n > 1) { | ||
| 17 | + for (; i < n; i++) | ||
| 18 | + method(); | ||
| 19 | + } | ||
| 17 | 20 | bench.start(); | |
| 18 | - for (; i < n; i++) method(); | ||
| 21 | + for (i = 0; i < n; i++) method(); | ||
| 19 | 22 | bench.end(n); | |
| 20 | 23 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,8 +22,6 @@ function defaultParams(x = 1, y = 2) { | |||
| 22 | 22 | ||
| 23 | 23 | function runOldStyleDefaults(n) { | |
| 24 | 24 | ||
| 25 | - common.v8ForceOptimization(oldStyleDefaults); | ||
| 26 | - | ||
| 27 | 25 | var i = 0; | |
| 28 | 26 | bench.start(); | |
| 29 | 27 | for (; i < n; i++) | |
@@ -33,8 +31,6 @@ function runOldStyleDefaults(n) { | |||
| 33 | 31 | ||
| 34 | 32 | function runDefaultParams(n) { | |
| 35 | 33 | ||
| 36 | - common.v8ForceOptimization(defaultParams); | ||
| 37 | - | ||
| 38 | 34 | var i = 0; | |
| 39 | 35 | bench.start(); | |
| 40 | 36 | for (; i < n; i++) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,8 +35,6 @@ function useArguments() { | |||
| 35 | 35 | ||
| 36 | 36 | function runCopyArguments(n) { | |
| 37 | 37 | ||
| 38 | - common.v8ForceOptimization(copyArguments, 1, 2, 'a', 'b'); | ||
| 39 | - | ||
| 40 | 38 | var i = 0; | |
| 41 | 39 | bench.start(); | |
| 42 | 40 | for (; i < n; i++) | |
@@ -46,8 +44,6 @@ function runCopyArguments(n) { | |||
| 46 | 44 | ||
| 47 | 45 | function runRestArguments(n) { | |
| 48 | 46 | ||
| 49 | - common.v8ForceOptimization(restArguments, 1, 2, 'a', 'b'); | ||
| 50 | - | ||
| 51 | 47 | var i = 0; | |
| 52 | 48 | bench.start(); | |
| 53 | 49 | for (; i < n; i++) | |
@@ -57,8 +53,6 @@ function runRestArguments(n) { | |||
| 57 | 53 | ||
| 58 | 54 | function runUseArguments(n) { | |
| 59 | 55 | ||
| 60 | - common.v8ForceOptimization(useArguments, 1, 2, 'a', 'b'); | ||
| 61 | - | ||
| 62 | 56 | var i = 0; | |
| 63 | 57 | bench.start(); | |
| 64 | 58 | for (; i < n; i++) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -4,9 +4,6 @@ const common = require('../common.js'); | |||
| 4 | 4 | const assert = require('assert'); | |
| 5 | 5 | const Writable = require('stream').Writable; | |
| 6 | 6 | const util = require('util'); | |
| 7 | - const v8 = require('v8'); | ||
| 8 | - | ||
| 9 | - v8.setFlagsFromString('--allow_natives_syntax'); | ||
| 10 | 7 | ||
| 11 | 8 | const methods = [ | |
| 12 | 9 | 'restAndSpread', | |
@@ -51,14 +48,7 @@ function usingArgumentsAndApplyC() { | |||
| 51 | 48 | nullStream.write(util.format.apply(null, arguments) + '\n'); | |
| 52 | 49 | } | |
| 53 | 50 | ||
| 54 | - function optimize(method, ...args) { | ||
| 55 | - method(...args); | ||
| 56 | - eval(`%OptimizeFunctionOnNextCall(${method.name})`); | ||
| 57 | - method(...args); | ||
| 58 | - } | ||
| 59 | - | ||
| 60 | 51 | function runUsingRestAndConcat(n) { | |
| 61 | - optimize(usingRestAndConcat, 'a', 1); | ||
| 62 | 52 | ||
| 63 | 53 | var i = 0; | |
| 64 | 54 | bench.start(); | |
@@ -70,7 +60,6 @@ function runUsingRestAndConcat(n) { | |||
| 70 | 60 | function runUsingRestAndSpread(n, concat) { | |
| 71 | 61 | ||
| 72 | 62 | const method = concat ? usingRestAndSpreadC : usingRestAndSpreadTS; | |
| 73 | - optimize(method, 'this is %s of %d', 'a', 1); | ||
| 74 | 63 | ||
| 75 | 64 | var i = 0; | |
| 76 | 65 | bench.start(); | |
@@ -82,7 +71,6 @@ function runUsingRestAndSpread(n, concat) { | |||
| 82 | 71 | function runUsingRestAndApply(n, concat) { | |
| 83 | 72 | ||
| 84 | 73 | const method = concat ? usingRestAndApplyC : usingRestAndApplyTS; | |
| 85 | - optimize(method, 'this is %s of %d', 'a', 1); | ||
| 86 | 74 | ||
| 87 | 75 | var i = 0; | |
| 88 | 76 | bench.start(); | |
@@ -94,7 +82,6 @@ function runUsingRestAndApply(n, concat) { | |||
| 94 | 82 | function runUsingArgumentsAndApply(n, concat) { | |
| 95 | 83 | ||
| 96 | 84 | const method = concat ? usingArgumentsAndApplyC : usingArgumentsAndApplyTS; | |
| 97 | - optimize(method, 'this is %s of %d', 'a', 1); | ||
| 98 | 85 | ||
| 99 | 86 | var i = 0; | |
| 100 | 87 | bench.start(); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -42,16 +42,16 @@ function usingICU(val) { | |||
| 42 | 42 | } | |
| 43 | 43 | ||
| 44 | 44 | function runPunycode(n, val) { | |
| 45 | - common.v8ForceOptimization(usingPunycode, val); | ||
| 46 | 45 | var i = 0; | |
| 47 | - bench.start(); | ||
| 48 | 46 | for (; i < n; i++) | |
| 49 | 47 | usingPunycode(val); | |
| 48 | + bench.start(); | ||
| 49 | + for (i = 0; i < n; i++) | ||
| 50 | + usingPunycode(val); | ||
| 50 | 51 | bench.end(n); | |
| 51 | 52 | } | |
| 52 | 53 | ||
| 53 | 54 | function runICU(n, val) { | |
| 54 | - common.v8ForceOptimization(usingICU, val); | ||
| 55 | 55 | var i = 0; | |
| 56 | 56 | bench.start(); | |
| 57 | 57 | for (; i < n; i++) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments