From eba2c62bb10fb65785050600212f70d38f1ffba3 Mon Sep 17 00:00:00 2001 From: Bartosz Sosnowski Date: Wed, 1 Mar 2017 12:37:12 +0100 Subject: [PATCH] benchmark: remove forced optimization from path This removes all instances of %OptimizeFunctionOnNextCall from path benchmarks PR-URL: https://github.com/nodejs/node/pull/9615 Reviewed-By: James M Snell Reviewed-By: Matteo Collina --- benchmark/path/basename-posix.js | 7 ------- benchmark/path/basename-win32.js | 7 ------- benchmark/path/dirname-posix.js | 7 ------- benchmark/path/dirname-win32.js | 7 ------- benchmark/path/extname-posix.js | 7 ------- benchmark/path/extname-win32.js | 7 ------- benchmark/path/format-posix.js | 7 ------- benchmark/path/format-win32.js | 7 ------- benchmark/path/isAbsolute-posix.js | 7 ------- benchmark/path/isAbsolute-win32.js | 7 ------- benchmark/path/join-posix.js | 7 ------- benchmark/path/join-win32.js | 7 ------- benchmark/path/makeLong-win32.js | 7 ------- benchmark/path/normalize-posix.js | 7 ------- benchmark/path/normalize-win32.js | 7 ------- benchmark/path/parse-posix.js | 12 ++++-------- benchmark/path/parse-win32.js | 12 ++++-------- benchmark/path/relative-posix.js | 12 ++++-------- benchmark/path/relative-win32.js | 12 +++++------- benchmark/path/resolve-posix.js | 7 ------- benchmark/path/resolve-win32.js | 7 ------- 21 files changed, 17 insertions(+), 150 deletions(-) diff --git a/benchmark/path/basename-posix.js b/benchmark/path/basename-posix.js index 64da9017793440..fc983c8074c940 100644 --- a/benchmark/path/basename-posix.js +++ b/benchmark/path/basename-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { pathext: [ @@ -30,12 +29,6 @@ function main(conf) { input = input.slice(0, extIdx); } - // Force optimization before starting the benchmark - p.basename(input, ext); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.basename)'); - p.basename(input, ext); - bench.start(); for (var i = 0; i < n; i++) { p.basename(input, ext); diff --git a/benchmark/path/basename-win32.js b/benchmark/path/basename-win32.js index a6214598790033..b493beb87c9e94 100644 --- a/benchmark/path/basename-win32.js +++ b/benchmark/path/basename-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { pathext: [ @@ -30,12 +29,6 @@ function main(conf) { input = input.slice(0, extIdx); } - // Force optimization before starting the benchmark - p.basename(input, ext); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.basename)'); - p.basename(input, ext); - bench.start(); for (var i = 0; i < n; i++) { p.basename(input, ext); diff --git a/benchmark/path/dirname-posix.js b/benchmark/path/dirname-posix.js index e7ea80ffa313c8..af77be5ac06559 100644 --- a/benchmark/path/dirname-posix.js +++ b/benchmark/path/dirname-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -21,12 +20,6 @@ function main(conf) { var p = path.posix; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.dirname(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.dirname)'); - p.dirname(input); - bench.start(); for (var i = 0; i < n; i++) { p.dirname(input); diff --git a/benchmark/path/dirname-win32.js b/benchmark/path/dirname-win32.js index 5cb0829437c2ed..01d97d08e2ae05 100644 --- a/benchmark/path/dirname-win32.js +++ b/benchmark/path/dirname-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -21,12 +20,6 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.dirname(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.dirname)'); - p.dirname(input); - bench.start(); for (var i = 0; i < n; i++) { p.dirname(input); diff --git a/benchmark/path/extname-posix.js b/benchmark/path/extname-posix.js index 61a1073158f8d3..50c4e8f7927ba6 100644 --- a/benchmark/path/extname-posix.js +++ b/benchmark/path/extname-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -24,12 +23,6 @@ function main(conf) { var p = path.posix; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.extname(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.extname)'); - p.extname(input); - bench.start(); for (var i = 0; i < n; i++) { p.extname(input); diff --git a/benchmark/path/extname-win32.js b/benchmark/path/extname-win32.js index 67e53eab85817f..9c0df13ab46105 100644 --- a/benchmark/path/extname-win32.js +++ b/benchmark/path/extname-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -24,12 +23,6 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.extname(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.extname)'); - p.extname(input); - bench.start(); for (var i = 0; i < n; i++) { p.extname(input); diff --git a/benchmark/path/format-posix.js b/benchmark/path/format-posix.js index b30b58be4118f0..ee78a6d5f30980 100644 --- a/benchmark/path/format-posix.js +++ b/benchmark/path/format-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { props: [ @@ -22,12 +21,6 @@ function main(conf) { name: props[4] || '', }; - // Force optimization before starting the benchmark - p.format(obj); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.format)'); - p.format(obj); - bench.start(); for (var i = 0; i < n; i++) { p.format(obj); diff --git a/benchmark/path/format-win32.js b/benchmark/path/format-win32.js index 7404f2e93e6868..9ec981d6310ed6 100644 --- a/benchmark/path/format-win32.js +++ b/benchmark/path/format-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { props: [ @@ -22,12 +21,6 @@ function main(conf) { name: props[4] || '', }; - // Force optimization before starting the benchmark - p.format(obj); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.format)'); - p.format(obj); - bench.start(); for (var i = 0; i < n; i++) { p.format(obj); diff --git a/benchmark/path/isAbsolute-posix.js b/benchmark/path/isAbsolute-posix.js index fb8956c073b9db..22db751100ceee 100644 --- a/benchmark/path/isAbsolute-posix.js +++ b/benchmark/path/isAbsolute-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -19,12 +18,6 @@ function main(conf) { var p = path.posix; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.isAbsolute(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.isAbsolute)'); - p.isAbsolute(input); - bench.start(); for (var i = 0; i < n; i++) { p.isAbsolute(input); diff --git a/benchmark/path/isAbsolute-win32.js b/benchmark/path/isAbsolute-win32.js index 57fb8b8999e838..a565da8e566f8f 100644 --- a/benchmark/path/isAbsolute-win32.js +++ b/benchmark/path/isAbsolute-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -20,12 +19,6 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.isAbsolute(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.isAbsolute)'); - p.isAbsolute(input); - bench.start(); for (var i = 0; i < n; i++) { p.isAbsolute(input); diff --git a/benchmark/path/join-posix.js b/benchmark/path/join-posix.js index 1222f4050aa6ab..a7cf3772522daa 100644 --- a/benchmark/path/join-posix.js +++ b/benchmark/path/join-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -15,12 +14,6 @@ function main(conf) { var p = path.posix; var args = ('' + conf.paths).split('|'); - // Force optimization before starting the benchmark - p.join.apply(null, args); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.join)'); - p.join.apply(null, args); - bench.start(); for (var i = 0; i < n; i++) { p.join.apply(null, args); diff --git a/benchmark/path/join-win32.js b/benchmark/path/join-win32.js index 86801859d56c3b..18c1e802a6bff1 100644 --- a/benchmark/path/join-win32.js +++ b/benchmark/path/join-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -15,12 +14,6 @@ function main(conf) { var p = path.win32; var args = ('' + conf.paths).split('|'); - // Force optimization before starting the benchmark - p.join.apply(null, args); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.join)'); - p.join.apply(null, args); - bench.start(); for (var i = 0; i < n; i++) { p.join.apply(null, args); diff --git a/benchmark/path/makeLong-win32.js b/benchmark/path/makeLong-win32.js index d4b29d7e709b3e..fe5da425a5cd73 100644 --- a/benchmark/path/makeLong-win32.js +++ b/benchmark/path/makeLong-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -18,12 +17,6 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p._makeLong(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p._makeLong)'); - p._makeLong(input); - bench.start(); for (var i = 0; i < n; i++) { p._makeLong(input); diff --git a/benchmark/path/normalize-posix.js b/benchmark/path/normalize-posix.js index 19d6461ca51dcf..aec703cbe21242 100644 --- a/benchmark/path/normalize-posix.js +++ b/benchmark/path/normalize-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -20,12 +19,6 @@ function main(conf) { var p = path.posix; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.normalize(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.normalize)'); - p.normalize(input); - bench.start(); for (var i = 0; i < n; i++) { p.normalize(input); diff --git a/benchmark/path/normalize-win32.js b/benchmark/path/normalize-win32.js index 119f9797681113..356d399c3513ab 100644 --- a/benchmark/path/normalize-win32.js +++ b/benchmark/path/normalize-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -20,12 +19,6 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.normalize(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.normalize)'); - p.normalize(input); - bench.start(); for (var i = 0; i < n; i++) { p.normalize(input); diff --git a/benchmark/path/parse-posix.js b/benchmark/path/parse-posix.js index ee4306fcd27496..997eec0452b74a 100644 --- a/benchmark/path/parse-posix.js +++ b/benchmark/path/parse-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -21,15 +20,12 @@ function main(conf) { var p = path.posix; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.parse(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.parse)'); - p.parse(input); - - bench.start(); for (var i = 0; i < n; i++) { p.parse(input); } + bench.start(); + for (i = 0; i < n; i++) { + p.parse(input); + } bench.end(n); } diff --git a/benchmark/path/parse-win32.js b/benchmark/path/parse-win32.js index 5a7b80f0ddb3da..2a95f758665377 100644 --- a/benchmark/path/parse-win32.js +++ b/benchmark/path/parse-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { path: [ @@ -22,15 +21,12 @@ function main(conf) { var p = path.win32; var input = '' + conf.path; - // Force optimization before starting the benchmark - p.parse(input); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.parse)'); - p.parse(input); - - bench.start(); for (var i = 0; i < n; i++) { p.parse(input); } + bench.start(); + for (i = 0; i < n; i++) { + p.parse(input); + } bench.end(n); } diff --git a/benchmark/path/relative-posix.js b/benchmark/path/relative-posix.js index 7544fb2dc67e7d..492b73c3e89f8a 100644 --- a/benchmark/path/relative-posix.js +++ b/benchmark/path/relative-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -26,15 +25,12 @@ function main(conf) { to = from.slice(delimIdx + 1); from = from.slice(0, delimIdx); } - - // Force optimization before starting the benchmark - p.relative(from, to); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.relative)'); - p.relative(from, to); + for (var i = 0; i < n; i++) { + p.relative(from, to); + } bench.start(); - for (var i = 0; i < n; i++) { + for (i = 0; i < n; i++) { p.relative(from, to); } bench.end(n); diff --git a/benchmark/path/relative-win32.js b/benchmark/path/relative-win32.js index 92531959c1c3aa..7e7620299eb16c 100644 --- a/benchmark/path/relative-win32.js +++ b/benchmark/path/relative-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -25,14 +24,13 @@ function main(conf) { from = from.slice(0, delimIdx); } - // Force optimization before starting the benchmark - p.relative(from, to); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.relative)'); - p.relative(from, to); + // Warmup + for (var i = 0; i < n; i++) { + p.relative(from, to); + } bench.start(); - for (var i = 0; i < n; i++) { + for (i = 0; i < n; i++) { p.relative(from, to); } bench.end(n); diff --git a/benchmark/path/resolve-posix.js b/benchmark/path/resolve-posix.js index 93e5b82191a23a..d1364a8ac256c9 100644 --- a/benchmark/path/resolve-posix.js +++ b/benchmark/path/resolve-posix.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -18,12 +17,6 @@ function main(conf) { var p = path.posix; var args = ('' + conf.paths).split('|'); - // Force optimization before starting the benchmark - p.resolve.apply(null, args); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.resolve)'); - p.resolve.apply(null, args); - bench.start(); for (var i = 0; i < n; i++) { p.resolve.apply(null, args); diff --git a/benchmark/path/resolve-win32.js b/benchmark/path/resolve-win32.js index dc0eb30e930049..6dfb38167c96bd 100644 --- a/benchmark/path/resolve-win32.js +++ b/benchmark/path/resolve-win32.js @@ -1,7 +1,6 @@ 'use strict'; var common = require('../common.js'); var path = require('path'); -var v8 = require('v8'); var bench = common.createBenchmark(main, { paths: [ @@ -18,12 +17,6 @@ function main(conf) { var p = path.win32; var args = ('' + conf.paths).split('|'); - // Force optimization before starting the benchmark - p.resolve.apply(null, args); - v8.setFlagsFromString('--allow_natives_syntax'); - eval('%OptimizeFunctionOnNextCall(p.resolve)'); - p.resolve.apply(null, args); - bench.start(); for (var i = 0; i < n; i++) { p.resolve.apply(null, args);