Because the standard deviation can't be calculated when there is only
one observation the R scripts raises an error. However it may still be
useful to run them for non-statistical purposes.
This changes the behaviour such when there is only one observation, the
values that depends on the standard deviation becomes Not Applicable
(NA).
Fixes: https://github.com/nodejs/node/issues/8288
PR-URL: https://github.com/nodejs/node/pull/8299
Reviewed-By: Anna Henningsen <anna@addaleax.net>
ESLint 3.5.0 introduces a `no-restricted-properties` rule. Replace our
custom `no-deepEqual` rule with this rule.
PR-URL: https://github.com/nodejs/node/pull/8478
Reviewed-By: James M Snell <jasnell@gmail.com>
Add very simple benchmarks for `fs.stat` and `fs.statSync` as
well as `fs.lstat` and `fs.lstatSync` based on the `readdir`
benchmarks.
PR-URL: https://github.com/nodejs/node/pull/8338
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Fix a off-by-one error that made the benchmarks for asynchronous
functions run `n - 1` times instead of `n` times.
PR-URL: https://github.com/nodejs/node/pull/8338
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
This adds support for multiple HTTP benchmarkers. Adds autocannon
as the secondary benchmarker.
PR-URL: https://github.com/nodejs/node/pull/8140
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Node documentation recommends using process.exitCode = x and returning
as a way to exit.
PR-URL: https://github.com/nodejs/node/pull/7961
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
I noticed some typos and the lack of {} following an if.
PR-URL: https://github.com/nodejs/node/pull/7961
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Andreas Madsen <amwebdk@gmail.com>
The benchmarks included also work for the previous JS
implementation of fs.realpath(). In case the new implementation of
realpath() needs to be reverted, we want these changes to stick around.
PR-URL: https://github.com/nodejs/node/pull/7899
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
* Add language specification for the txt code blocks.
* Move the definitions to the bottom.
Ref: https://github.com/nodejs/node/pull/7727
PR-URL: https://github.com/nodejs/node/pull/7727
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Strings where never mutable, it is not clear what this benchmarks
attempts to do. This did work at some point, but only because the
benchmark wasn't using strict mode.
PR-URL: https://github.com/nodejs/node/pull/7094
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Previously this a tool in `plot.R`. It is now are more complete tool
which executes the benchmarks many times and creates a boxplot.
PR-URL: https://github.com/nodejs/node/pull/7094
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
The data sampling is done in node and the data processing is done in R.
Only plyr was added as an R dependency and it is fairly standard.
PR-URL: https://github.com/nodejs/node/pull/7094
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Previously bench.end would call process.exit(0) however this is rather
confusing and indeed a few benchmarks had code that assumed otherwise.
This adds process.exit(0) to the benchmarks that needs it.
PR-URL: https://github.com/nodejs/node/pull/7094
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This removes the need for parsing stdout from the benchmarks. If the
process wasn't executed by fork, it will just print like it used to.
This also fixes the parsing of CLI arguments, by inferring the type
from the options object instead of the value content.
Only two benchmarks had to be changed:
* http/http_server_for_chunky_client.js this previously used a spawn
now it uses a fork and relays the messages using common.sendResult.
* misc/v8-bench.js this utilized that v8/benchmark/run.js called
global.print and reformatted the input. It now interfaces directly
with the benchmark runner global.BenchmarkSuite.
PR-URL: https://github.com/nodejs/node/pull/7094
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
It wasn't obviouse that common.js was the main cli tool.
PR-URL: https://github.com/nodejs/node/pull/7094
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
These files are very old and undocumented. Most likely nobody are
using them.
PR-URL: https://github.com/nodejs/node/pull/7094
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This change is in preparation for lint-enforced brace style.
PR-URL: https://github.com/nodejs/node/pull/7630
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Remove variables that are assigned but never used.
(This was missed by the linter in previous versions of ESLint but is
flagged by the current version. Updating the linter is contingent on
this change or some similar remedy landing.)
PR-URL: https://github.com/nodejs/node/pull/7600
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
ICU has a punycode implementation built in. Use it instead of the
javascript implementation because it's much faster.
PR-URL: https://github.com/nodejs/node/pull/7355
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Timings for sequential and concurren setImmediate() with and without
arguments, and set + clearImmediate().
PR-URL: https://github.com/nodejs/node/pull/6436
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
* Speed up buffer.swap16 and swap32 by using builtins. Up to ~6x gain.
Drop transition point between JS and C++ implementations accordingly.
Amount of performance improvement not only depends on buffer size but
also memory alignment.
* Fix tests: C++ impl tests were testing 0-filled buffers so were
always passing.
* Add similar buffer.swap64 method.
* Make buffer-swap benchmark mirror JS impl.
doc/api/buffer.markdown has an entry of "added: REPLACEME" that should
be changed to the correct release number before tagged.
Because node is currently using a very old version of cpplint.py it
doesn't know that std::swap() has moved from <algorithm> to <utility> in
c++11. So until cpplint.py is updated simply NOLINT the line.
Technically it should be NOLINT(build/include_what_you_use), but that
puts the line over 80 characters causing another lint error.
PR-URL: https://github.com/nodejs/node/pull/7157
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
To copy the values of all enumerable own properties from-
a source object to a target object, node still use-
`util._extend`, though newer standard `Object.assign`
is available. This is because `util._extend` is found to
be faster than `Object.assign`. This benchmark test is
to keep track of how performance compare.
PR-URL: https://github.com/nodejs/node/pull/7255
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
read() performance is improved most by switching from an array to
a linked list for storing buffered data. However, other changes that
also contribute include: making some hot functions inlinable, faster
read() argument checking, and misc code rearrangement to avoid
unnecessary code execution.
PR-URL: https://github.com/nodejs/node/pull/7077
Reviewed-By: Calvin Metcalf <calvin.metcalf@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit optimizes checkInvalidHeaderChar() by unrolling the
character checking loop a bit.
Additionally, some changes to the benchmark runner are needed in
order for the included benchmark to be run correctly. Specifically,
the regexp used to parse `key=value` parameters contained a greedy
quantifier that was causing the `key` to match part of the `value`
if `value` contained an equals sign.
PR-URL: https://github.com/nodejs/node/pull/6570
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
This benchmark fails on Windows when trying to execute command which
is more than 32k in size. This commits skips this one case when running
under Windows.
PR-URL: https://github.com/nodejs/node/pull/7178
Reviewed-By: Trott - Rich Trott <rtrott@gmail.com>
Reviewed-By: orangemocha - Alexis Campailla <orangemocha@nodejs.org>
Under Windows 'ipc' communication requires the other process to format
its messages with 'IPC framing protocol'. Otherwise, an assert is
triggered in libuv. This commit changes child-process-read benchmark
to use stdout to communicate with parent process. It also adds
child-process-read-ipc.js to benchmark IPC communication using
child node process.
PR-URL: https://github.com/nodejs/node/pull/6971
Reviewed-By: João Reis <reis@janeasystems.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit provides a rewrite of StringDecoder that both improves
performance (for non-single-byte encodings) and understandability.
Additionally, StringDecoder instantiation performance has increased
considerably due to inlinability and more efficient encoding name
checking.
PR-URL: https://github.com/nodejs/node/pull/6777
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Improves numbers up to 4x by avoiding repetitive dynamic method lookup.
PR-URL: https://github.com/nodejs/node/pull/6922
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
In preparation for stricter linting, remove extra spaces.
PR-URL: https://github.com/nodejs/node/pull/6645
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Roman Reiss <me@silverwind.io>
In certain conditions, inspecting a Proxy object can lead to a
max call stack error. Avoid that by detecting the Proxy object
and outputting information about the Proxy object itself.
Fixes: https://github.com/nodejs/node/issues/6464
PR-URL: https://github.com/nodejs/node/pull/6465
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Net benchmarks create partial event emitters that do not have all of the
required event emitter functions. They currently mock out `on`, `once`,
and `emit` functions. This change mocks out `prependListener` as well to
avoid crashing in `_stream_readable`.
PR-URL: https://www.github.com/nodejs/node/pull/6407
Fixes: https://www.github.com/nodejs/node/issues/6405
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: Matthew Loring <mattloring@google.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
In preparation for a lint rule that will enforce
assert.deepStrictEqual() over assert.deepEqual(), change tests and
benchmarks accordingly. For tests and benchmarks that are testing or
benchmarking assert.deepEqual() itself, apply a comment to ignore the
upcoming rule.
PR-URL: https://github.com/nodejs/node/pull/6213
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Adds new microbenchmarks for destructuring, rest params and
default params.
PR-URL: https://github.com/nodejs/node/pull/6222
Reviewed-By: Brian White <mscdex@mscdex.net>
It's useful to be able to force optimization of a function.
Rather than duplicating the code everywhere for it, let's
make a utility available.
PR-URL: https://github.com/nodejs/node/pull/6222
Reviewed-By: Brian White <mscdex@mscdex.net>
Overall cleanup in code, eliminate reliance on `arguments`.
Benchmarks show that as of v8 5.0.71.32, using rest params + apply
has good performance. The spread operator is not yet well optimized
in v8
```
misc/console.js method=restAndSpread concat=1 n=1000000: 374779.38359
misc/console.js method=restAndSpread concat=0 n=1000000: 375988.30434
misc/console.js method=argumentsAndApply concat=1 n=1000000: 682618.61125
misc/console.js method=argumentsAndApply concat=0 n=1000000: 645093.74443
misc/console.js method=restAndApply concat=1 n=1000000: 682931.41217
misc/console.js method=restAndApply concat=0 n=1000000: 664473.09700
```
PR-URL: https://github.com/nodejs/node/pull/6233
Reviewed-By: Brian White <mscdex@mscdex.net>
Aligns the functionality of SlowBuffer with the new Buffer
constructor API. Next step is to docs-only deprecate
SlowBuffer.
Replace the internal uses of SlowBuffer with
`Buffer.allocUnsafeSlow(size)`
PR-URL: https://github.com/nodejs/node/pull/5833
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Adds additional `targetStart`, `targetEnd`, `sourceStart,
and `sourceEnd` arguments to `Buffer.prototype.compare`
to allow comparison of sub-ranges of two Buffers without
requiring Buffer.prototype.slice()
Fixes: https://github.com/nodejs/node/issues/521
PR-URL: https://github.com/nodejs/node/pull/5880
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
When create Buffer from empty string will touch
C++ binding also.
This patch can improve edge case ~70% faster.
PR-URL: https://github.com/nodejs/node/pull/4414
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
4d78121b77 had lint errors that went
undetected. This fixes them.
PR-URL: https://github.com/nodejs/node/pull/5840
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
use String.prototype.repeat() to simplify code, less code,
more semantically.
PR-URL: https://github.com/nodejs/node/pull/5359
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit improves setImmediate() performance by moving the
try-finally block that wraps callback execution into a separate
function because currently v8 never tries to optimize functions
that contain try-finally blocks.
With this change, there is a ~20-40% improvement in the included
setImmediate() depth benchmarks. The breadth benchmarks show a slight
improvement.
PR-URL: https://github.com/nodejs/node/pull/4169
Reviewed-By: Minwoo Jung <jmwsoft@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Several changes:
* Soft-Deprecate Buffer() constructors
* Add `Buffer.from()`, `Buffer.alloc()`, and `Buffer.allocUnsafe()`
* Add `--zero-fill-buffers` command line option
* Add byteOffset and length to `new Buffer(arrayBuffer)` constructor
* buffer.fill('') previously had no effect, now zero-fills
* Update the docs
PR-URL: https://github.com/nodejs/node/pull/4682
Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
Enabled no-self-assign rule in ESLint.
This required one change in a benchmark file. Changed a loop (that is
outside of the benchmark itself, so performance is not critical) from a
for loop that repeats a string to use String.prototype.repeat() instead.
While at it, took the opportunity to const-ify the benchmark file.
Also moved the "Strict" section in the .eslintrc to match where it is in
the ESLint documentation. Updated the link for Strict rules to point to
the ESLint website rather than the GitHub-hosted code.
PR-URL: https://github.com/nodejs/node/pull/5552
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
PR-URL: https://github.com/nodejs/node/pull/5517
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Evan Lucas <evanlucas@me.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Array#pop() is known to be faster than Array#shift().
To be exact, it's O(1) vs. O(n). In this case there's no difference
from which side of the "pool" array the object is retrieved,
so .pop() should be preferred.
PR-URL: https://github.com/nodejs/node/pull/2174
Reviewed-By: mscdex - Brian White <mscdex@mscdex.net>
Reviewed-By: jasnell - James M Snell <jasnell@gmail.com>
Reviewed-By: ofrobots - Ali Ijaz Sheikh <ofrobots@google.com>
In order to comply with linting rules used in the rest of the code base,
eliminate redeclared variables. A conservative approach is used so as to
avoid unintentional performance issues (for example, as might be seen in
some situations when using `let` instead of `var`).
PR-URL: https://github.com/nodejs/node/pull/5468
Reviewed-By: Brian White <mscdex@mscdex.net>
There is a benchmark for the class method `Buffer.compare()` but not for
the instance method `buf.compare()`. This adds that benchmark.
I used this to confirm a performance regression in an implementation I
was considering. While the implementation was a bust, it does seem like
the benchmark is worthwhile.
The benchmark is nearly identical to the existing `Buffer.compare()`
benchmark except, of course, that it calls `buf.compare()` instead.
PR-URL: https://github.com/nodejs/node/pull/5441
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Evan Lucas <evanlucas@me.com>
In the hopes of soon having the benchmark code linted, this change
groups all the likely non-controversial lint-compliance changes such as
indentation, semi-colon usage, and single-vs.-double quotation marks.
Other lint rules may have subtle performance implications in the V8
currently shipped with Node.js. Those changes will require more careful
review and will be in a separate change.
PR-URL: https://github.com/nodejs/node/pull/5429
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Brian White <mscdex@mscdex.net>
The benchmark runner spawns new processes for each configuration. The
specific configuration is transfered by process.argv. This means that
the values have to be parsed. As of right now only numbers and strings
are parsed correctly. However other values such as objects where used.
This fixes the benchmarks that used non-string/number values and
prevents future issues by asserting the type.
PR-URL: https://github.com/nodejs/node/pull/5177
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
url.js was broken since it didn't use the common.js runner. This fixes
that issue by merging it with url-resolve.js, which also benchmarks
url.resolve.
PR-URL: https://github.com/nodejs/node/pull/5177
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rod Vagg <rod@vagg.org>
Apply strict mode to benchmark code.
PR-URL: https://github.com/nodejs/node/pull/5336
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit improves escape() performance by up to 15% with the
existing querystring-stringify benchmarks by reducing the number
of string concatentations. A potential deopt is also avoided by
making sure the index passed to charCodeAt() is within bounds.
PR-URL: https://github.com/nodejs/node/pull/5012
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit improves parse() performance by ~20-200% with the various
querystring-parse benchmarks.
Some optimization strategies used in this commit include:
* Combining multiple searches (for '&', '=', and '+') on the same
string into a single loop
* Avoiding string.split()
* Minimizing creation of temporary strings
* Avoiding string decoding if no encoded bytes were found and the
default string decoder is being used
PR-URL: https://github.com/nodejs/node/pull/5012
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit splits each path benchmark into separate posix and
Windows benchmark files. This allows benchmarking (platform-)specific
inputs against specific platforms (only).
PR-URL: https://github.com/nodejs/node/pull/5123
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: James M Snell <jasnell@gmail.com>
Added ability to dgram.send to send multiple buffers, _writev style.
The offset and length parameters in dgram.send are now optional.
Refactored the dgram benchmarks, and seperated them from net.
Added docs for the new signature.
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Saúl Ibarra Corretgé <saghul@gmail.com>
Fixes: https://github.com/nodejs/node/issues/4302
PR-URL: https://github.com/nodejs/node/pull/4374
Constant declaration for `net` is omitted in `idle_server.js`
Add a constant declaration for constant `net`
PR-URL: https://github.com/nodejs/node/pull/3950
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
These changes improve parse() performance from ~11-30% on all of
the existing querystring benchmarks.
PR-URL: https://github.com/nodejs/node/pull/4675
Reviewed-By: Johan Bergström <bugs@bergstroem.nu>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
The `util.format()` is used frequently, make the method faster
is better.
R-URL: https://github.com/nodejs/node/pull/3964
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
When create Buffer from a Buffer will copy data
from old to new even though length is zero.
This patch can improve edge case 4x faster.
following is benchmark results.
new: buffers/buffer_zero.js n=1024: 2463.53891
old: buffers/buffer_zero.js n=1024: 618.70801
PR-URL: https://github.com/nodejs/node/pull/4326
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
assert.deepEqual: when actual and expected are typed arrays,
wrap them in a new Buffer each to increase performance
significantly.
PR-URL: https://github.com/nodejs/node/pull/4330
Fixes: https://github.com/nodejs/node/issues/4294
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Roman Reiss <me@silverwind.io>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
process.hrtime() was performing too many operations in C++ that could be
done faster in JS. Move those operations over by creating a length 4
Uint32Array and perform bitwise operations on the seconds so that it was
unnecessary for the native API to do any object creation or set any
fields.
This has improved performance from ~350 ns/op to ~65 ns/op. Light
benchmark included to demonstrate the performance change.
PR-URL: https://github.com/nodejs/node/pull/3780
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Improve performance by pushing directory entries to returned array in
batches of 8 using pushValueToArray() in JS. Add benchmarks to
demonstrate this improvement.
PR-URL: https://github.com/nodejs/node/pull/3780
Reviewed-By: Fedor Indutny <fedor@indutny.com>
For performance add headers to the headers Array by pushing them on from
JS. Benchmark added to demonstrate this case.
PR-URL: https://github.com/nodejs/node/pull/3780
Reviewed-By: Fedor Indutny <fedor@indutny.com>
The CoC requests to avoid the casual use of profanity.
PR-URL: https://github.com/nodejs/node/pull/4122
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: targos - Michaël Zasso <mic.besace@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
Adds the string search implementation from v8
which uses naive search if pattern length < 8
or to a specific badness then uses Boyer-Moore-Horspool
Added benchmark shows the expected improvements
Added option to use ucs2 encoding with Buffer::IndexOf
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
PR-URL: https://github.com/nodejs/node/pull/2539
Very minor update in benchmark/common.js
Not exactly a critical change, just continued cleaning
out of old joyent/node PRs that never landed.
Ref: https://github.com/nodejs/node-v0.x-archive/pull/8515
PR-URL: https://github.com/nodejs/node/pull/2399
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
Reviewed-By: Michaël Zasso <mic.besace@gmail.com>
This commit replaces instances of io.js with Node.js, based on the
recent convergence. There are some remaining instances of io.js,
related to build and the installer.
Fixes: https://github.com/nodejs/node/issues/2361
PR-URL: https://github.com/nodejs/node/pull/2367
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: João Reis <reis@janeasystems.com>
As per the discussion in #734, this patch deprecates the usage of
`EventEmitter.listenerCount` static function in the docs, and introduces
the `listenerCount` function in the prototype of `EventEmitter` itself.
PR-URL: https://github.com/nodejs/node/pull/2349
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Brian White <mscdex@mscdex.net>
As a follow-up to 0d15161, this commit adds benchmarks for the rest
of the path functions and also forces V8 to optimize the functions
before starting the benchmark test.
PR-URL: https://github.com/nodejs/io.js/pull/2103
Reviewed-By: Brendan Ashworth <brendan.ashworth@me.com>
Make the inner loop execute fewer compare-and-branch executions per
processed byte, resulting in a 50% or more speedup.
This coincidentally fixes an out-of-bounds read:
while (unbase64(*src) < 0 && src < srcEnd)
Should have read:
while (src < srcEnd && unbase64(*src) < 0)
But this commit removes the offending code altogether.
Fixes: https://github.com/nodejs/io.js/issues/2166
PR-URL: https://github.com/nodejs/io.js/pull/2193
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
In http_bench.js, allow the concurrent requests per client
to be configurable.
This also changes the launch of clients to wait until all
forked servers are online. This eliminates spurious error
messages at the start of the run.
PR-URL: https://github.com/nodejs/io.js/pull/2068
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Break up Buffer#toString() into a fast and slow path. The fast path
optimizes for zero-length buffers and no-arg method invocation.
The speedup for zero-length buffers is a satisfying 700%. The no-arg
toString() operation gets faster by about 13% for a one-byte buffer.
This change exploits the fact that most Buffer#toString() calls are
plain no-arg method calls. Rewriting the method to take no arguments
means a call doesn't go through an ArgumentsAdaptorTrampoline stack
frame in the common case.
PR-URL: https://github.com/nodejs/io.js/pull/2027
Reviewed-By: Brian White <mscdex@mscdex.net>
Reviewed-By: Christian Tellnes <christian@tellnes.no>
Reviewed-By: Daniel Cousens <email@dcousens.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Buffer.byteLength is important for speed because it is called whenever a
new Buffer is created from a string.
This commit optimizes Buffer.byteLength execution by:
- moving base64 length calculation into JS-land, which is now much
faster
- remove redundant code and streamline the UTF8 length calculation
It also adds a benchmark and better tests.
PR-URL: https://github.com/nodejs/io.js/pull/1713
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit uses separate functions to isolate deopts caused by
try-catches and avoids fn.apply() for callbacks with small numbers
of arguments.
These changes improve performance by ~1-40% in the various
nextTick benchmarks.
PR-URL: https://github.com/iojs/io.js/pull/1571
Reviewed-By: Trevor Norris <trev.norris@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
When running a non-http benchmark, there is no need the check for the
wrk tool so move the wrk check into the http method.
PR-URL: https://github.com/iojs/io.js/pull/1368
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit fixes a few things for this benchmark:
1. Ensures the temporary directory for the unix socket exists.
2. Prevents the client code from being run directly because the
server script is the one that calls out the client code.
3. Ensures the server is closed once the client benchmarks have
finished.
4. Since this is an http benchmark, it should be moved to the http
benchmarks subdirectory.
PR-URL: https://github.com/iojs/io.js/pull/1257
Reviewed-By: Roman Reiss <me@silverwind.io>
By limiting property getting/setting to only where they are
absolutely necessary, we can achieve greater performance
especially with small utf8 inputs and any size base64 inputs.
PR-URL: https://github.com/iojs/io.js/pull/1209
Reviewed-By: Rod Vagg <rod@vagg.org>
Reviewed-By: Nicu Micleușanu <micnic90@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
This commit adds an `OUTPUT_FORMAT` environment variable option for
all benchmark tests that allow either 'csv' or 'default' output. Default
output has been left unchanged, and csv output prints out the csv
headers along with the csv formatted per-test output, each test also
seperated by a newline.
It can be used like the following:
$ OUTPUT_FORMAT=csv iojs benchmark/common.js http
Not specifying the OUTPUT_FORMAT env var will default to 'default'.
Specifying a bad value will throw an error.
PR-URL: https://github.com/iojs/io.js/pull/777
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
This commit adds a graphing script (in R) for graphing the CSV output
of a benchmark. It can be run like this:
```
$ OUTPUT_FORMAT=csv iojs benchmark/http/client-request-body.js >
data.csv
$ ./benchmark/plot_csv.R data.csv graph.png bytes type
```
This will graph the output to `graph.png`, using the output's `bytes`
value as X and the result value for each as Y. Output will be grouped
by `type`.
Running as the example yields a beautiful graph like this:
http://pbrd.co/1vBhUfy.
PR-URL: https://github.com/iojs/io.js/pull/777
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
wrk is an optional tool that some of the http benchmarks uses. The removal
doesn't affect any users. Developers are assumed to install it before running
the tests.
This change reduces the tarball by 5%
PR-URL: https://github.com/iojs/io.js/pull/982
Reviewed-By: Rod Vagg <rod@vagg.org>
Benchmarker should pass exec flags (e.g. --no-crankshaft,
--turbofan-filter, --trace-opt etc) to the benchmarking process
Reviewed-By: Sam Roberts <vieuxtech@gmail.com>
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
PR-URL: https://github.com/iojs/io.js/pull/928
Some of the benchmarks that were added in commit 847b9d2 complete too
quickly to draw meaningful conclusions from. Increase the number of
iterations to make them run longer.
PR-URL: https://github.com/iojs/io.js/pull/746
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Before this commit, only benchmark targets defined in Makefile could
be used. This commit allows execution of common.js directly and
passing of filter arguments directly, allowing you to run either a
subset of benchmarks or a single specific benchmark for comparison.
PR-URL: https://github.com/iojs/io.js/pull/711
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
When running benchmark/compare.js, it is typical to run a version of
node that does not support template strings. This provides backwards
compatibility for comparing benchmarks using older versions of node.
PR-URL: https://github.com/iojs/io.js/pull/714
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
This commit cleans up `benchmark/common.js` with a few generic changes
such as the following:
- declare all `require()`'d libraries at the top instead of in the
middle
- add some empty whitespace where it helps readability
- changes ambiguous variable names
- standardizes most if / else blocks
- missing semicolons
PR-URL: https://github.com/iojs/io.js/pull/662
Reviewed-By: Nicu Micleușanu <micnic90@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
This commit removes the benchmark spacing modification in
`client-request-body.js` and `end-vs-write-end.js` which adds two spaces
to the end of some variables to make sure the lines line up.
The reason behind this is that its totally pointless (the lines don't
actually line up with it) and it disallows you to parse the output with
a tool like awk, or at least makes it a lot harder.
PR-URL: https://github.com/iojs/io.js/pull/650
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Adds info on the `wrk` prerequisite for http benchmarks and how to
run benchmarks with options.
PR-URL: https://github.com/iojs/io.js/pull/629
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Evan Lucas <evanlucas@me.com>
This makes possible to use `for..of` loop with
buffers. Also related `keys`, `values` and `entries`
methods are added for feature parity with `Uint8Array`.
PR-URL: https://github.com/iojs/io.js/pull/525
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Fix up the tcp raw benchmarks after an internal API change.
PR-URL: https://github.com/iojs/io.js/pull/495
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
deps/v8/benchmarks/regexp.js clobbers the RegExp global, breaking
util.format() and console.log(). Unclobber it to keep the other
benchmarks working.
Fixes the following error when running benchmark/misc/v8-bench.js:
$ out/Release/iojs benchmark/misc/v8-bench.js
util.js:84
if (new RegExp('\\b' + set + '\\b', 'i').test(debugEnviron)) {
^
TypeError: object is not a function
at Object.exports.debuglog (util.js:84:9)
at timers.js:12:29
at NativeModule.compile (node.js:800:5)
at NativeModule.require (node.js:769:18)
at net.js:5:14
at NativeModule.compile (node.js:800:5)
at NativeModule.require (node.js:769:18)
at tty.js:4:11
at NativeModule.compile (node.js:800:5)
at Function.NativeModule.require (node.js:769:18)
This could alternatively be addressed by caching the RegExp global
in lib/util.js. That's not a bad approach and I considered it but
doing it for just RegExp and not other globals would be half-baked.
Maybe the more thorough approach where we cache all globals at
start-up is something for a follow-up pull request.
Fixes: https://github.com/iojs/io.js/pull/475
PR-URL: https://github.com/iojs/io.js/pull/489
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yosuke Furukawa <yosuke.furukawa@gmail.com>
Before:
# common.js executes all tests in net directory.
$ ./iojs common.js net
After:
# common.js executes only "dgram" tests in net directory.
$ ./iojs common.js net dgram
PR-URL: https://github.com/iojs/io.js/pull/488
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
The copyright and license notice is already in the LICENSE file. There
is no justifiable reason to also require that it be included in every
file, since the individual files are not individually distributed except
as part of the entire package.
Replace the call to Array#splice() with a faster open-coded version
that creates less garbage.
Add a new benchmark to prove it. With the change applied, it scores
about 5% higher and that is nothing to sneeze at.
PR-URL: https://github.com/iojs/io.js/pull/184
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Rename the url.parse() benchmark from url.js to url-parse.js.
A follow-up commit is going to add another one for url.resolve().
PR-URL: https://github.com/iojs/io.js/pull/184
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Replace the call to Array#splice() with a faster open-coded version
that creates less garbage.
Add a new benchmark to prove it. With the change applied, it scores
a whopping 40% higher.
PR-URL: https://github.com/iojs/io.js/pull/185
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Don't use Number#toPrecision(), it switches to scientific notation for
numbers with more digits than the precision; use Number#toFixed().
PR-URL: https://github.com/iojs/io.js/pull/185
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Force V8 to optimize url.parse() before starting the actual benchmark.
Tries to minimize variance between successive runs caused by the
optimizer kicking in at different points.
It does not seem to have much impact, CPU times are roughly the same
before and afterwards; url.parse() quickly plateaus at a local optimum
where most time is spent in V8 builtins, notably Runtime_StringSplit()
and Object::GetElementWithReceiver() calls originating from
deps/v8/src/uri.js, with no recurring optimize/deoptimize cycles that
I could spot.
Still, I don't see any downsides to pre-optimizing the function being
benchmarked so in it goes.
PR-URL: https://github.com/iojs/io.js/pull/132
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Fedor Indutny <fedor@indutny.com>
Adds the feature to define arguments for the function called in
domain.run(), this is supposed to be useful when a function is called from
another context and some values from the current context are needed as
arguments, it's similar to the callback from setTimeout or setInterval.
PR-URL: https://github.com/iojs/io.js/pull/15
Reviewed-By: Chris Dickinson <christopher.s.dickinson@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Based on the ad-hoc benchmark from joyent/node#8638 plus an additional
benchmark for user:pass auth URLs.
PR-URL: https://github.com/iojs/io.js/pull/102
Reviewed-by: Chris Dickinson <christopher.s.dickinson@gmail.com>
Adds a test for benchmarking the module loader, needed for benchmarking
changes / refacortings in the module loader.
Reviewed-by: Trevor Norris <trev.norris@gmail.com>
Reviewed-by: Timothy J Fontaine <tjfontaine@gmail.com>
The test is supposed to measure the performance of the base64 encoder
so move the Buffer#write() calls out of the benchmark section.
The overhead of the calls isn't terrible (about 1-3%) but having
unrelated activity in a micro-benchmark is never a good idea.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
compare() works like String.localeCompare such that:
Buffer.compare(a, b) === a.compare(b);
equals() does a native check to see if two buffers are equal.
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Increase the performance and simplify the logic of Buffer#write{U}Int*
and Buffer#read{U}Int* methods by placing the byte manipulation code
directly inline.
Also improve the speed of buffer-write benchmarks by creating a new
call directly to each method by using Function() instead of calling by
buff[fn].
Signed-off-by: Trevor Norris <trev.norris@gmail.com>
Since the SlabAllocator was removed the buffer length/offset is no
longer sent to the onread callback. The benchmarks have been updated to
reflect that.
This commit adds an optimization to the HTTP client that makes it
possible to:
* Pack the headers and the first chunk of the request body into a
single write().
* Pack the chunk header and the chunk itself into a single write().
Because only one write() system call is issued instead of several,
the chances of data ending up in a single TCP packet are phenomenally
higher: the benchmark with `type=buf size=32` jumps from 50 req/s to
7,500 req/s, a 150-fold increase.
This commit removes the check from e4b716ef that pushes binary encoded
strings into the slow path. The commit log mentions that:
We were assuming that any string can be concatenated safely to
CRLF. However, for hex, base64, or binary encoded writes, this
is not the case, and results in sending the incorrect response.
For hex and base64 strings that's certainly true but binary strings
are 'das Ding an sich': string.length is the same before and after
decoding.
Fixes #5528.
The benchmark compare would drop the last run of the binary pairs. So
when they were only run once an error would arise because no data was
generated for the second binary.
The benefits of the hot-path optimization below start to fall off when
the buffer size gets up near 128KB, because the cost of the copy is more
than the cost of the extra write() call. Switch to the write/end method
at that point.
Heuristics and magic numbers are awful, but slow http responses are
worse.
Fix #4975
This will run the benchmarks the number of times specified by NODE_BENCH_RUNS,
to attempt to reduce variability.
If the number of runs is high enough, it'll also throw out the top and bottom
quartiles, since that's where the outliers will be.
It's not very fancy statistics-fu, but it's better than nothing.
Also, linted this file. It had tabs in it. TABS!
For throughput benchmarks, run with just 5s durations rather than 1s and 3s.
For startup benchmark, run with just a single 1s duration, since it's very
consistent anyway.
This increases fs.WriteStream throughput dramatically by removing the
"higher default water marks" for fs.WriteStream.
Also includes a benchmark. Current performance is significantly higher
than v0.8 for strings at all tested levels except size=1. Buffer
performance is still lackluster.
Further improvement in the stream.Writable base class is required, but
this is a start.
Improvements:
* floating point operations are approx 4x's faster
* Now write quiet NaN's
* all read/write on floating point now done in C, so no more need for
lib/buffer_ieee754.js
* float values have more accurate min/max value checks
* add additional benchmarks for buffers read/write
* created benchmark/_bench_timer.js which is a simple library that
can be included into any benchmark and provides an intelligent tracker
for sync and async tests
* add benchmarks for DataView set methods
* add checks and tests to make sure offset is greater than 0
Remove a lot of branches from the inner loop. Speeds up buf.toString('base64')
by about 20%.
Before:
$ time out/Release/node benchmark/buffer-base64-encode.js
real 0m6.607s
user 0m5.508s
sys 0m1.088s
After:
$ time out/Release/node benchmark/buffer-base64-encode.js
real 0m5.520s
user 0m4.520s
sys 0m0.992s
This is very similar to http.sh, but generates a flamegraph
with dtrace, pruning off the single-hit stacks so that we can
more easily see the places where relevant amounts of time are
spent.
Just sends a buffer to a server, which echoes it back, and then measures
the Gbits/second. Very similar to throughput.js, but using a single
process, so that it's possible to dtrace and get the jsstack frames for
profile comparison.