| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent dcfda10 commit ffdc046
1 file changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,29 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + const common = require('../common.js'); | ||
| 3 | + const v8 = require('v8'); | ||
| 4 | + | ||
| 5 | + const bench = common.createBenchmark(main, { | ||
| 6 | + size: [16, 512, 1024, 4096, 16386], | ||
| 7 | + millions: [1] | ||
| 8 | + }); | ||
| 9 | + | ||
| 10 | + function main(conf) { | ||
| 11 | + const iter = (conf.millions >>> 0) * 1e6; | ||
| 12 | + const size = (conf.size >>> 0); | ||
| 13 | + const b0 = new Buffer(size).fill('a'); | ||
| 14 | + const b1 = new Buffer(size).fill('a'); | ||
| 15 | + | ||
| 16 | + b1[size - 1] = 'b'.charCodeAt(0); | ||
| 17 | + | ||
| 18 | + // Force optimization before starting the benchmark | ||
| 19 | + b0.compare(b1); | ||
| 20 | + v8.setFlagsFromString('--allow_natives_syntax'); | ||
| 21 | + eval('%OptimizeFunctionOnNextCall(b0.compare)'); | ||
| 22 | + b0.compare(b1); | ||
| 23 | + | ||
| 24 | + bench.start(); | ||
| 25 | + for (var i = 0; i < iter; i++) { | ||
| 26 | + b0.compare(b1); | ||
| 27 | + } | ||
| 28 | + bench.end(iter / 1e6); | ||
| 29 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments