This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'nodejs/master'
Sync to nodejs/master (3/25/2016) at nodejs/node@8363ede PR-URL: #46 Reviewed-By: Sandeep Agarwal <Agarwal.Sandeep@microsoft.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
- Loading branch information
Showing
148 changed files
with
4,820 additions
and
4,153 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,49 @@ | ||
#!/bin/bash | ||
|
||
if [ -z "$2" ]; then | ||
ARCH=arm | ||
else | ||
ARCH="$2" | ||
fi | ||
|
||
CC_VER="4.9" | ||
case $ARCH in | ||
arm) | ||
DEST_CPU="$ARCH" | ||
SUFFIX="$ARCH-linux-androideabi" | ||
TOOLCHAIN_NAME="$SUFFIX" | ||
;; | ||
x86) | ||
DEST_CPU="ia32" | ||
SUFFIX="i686-linux-android" | ||
TOOLCHAIN_NAME="$ARCH" | ||
;; | ||
x86_64) | ||
DEST_CPU="ia32" | ||
SUFFIX="$ARCH-linux-android" | ||
TOOLCHAIN_NAME="$ARCH" | ||
;; | ||
*) | ||
echo "Unsupported architecture provided: $ARCH" | ||
exit 1 | ||
;; | ||
esac | ||
|
||
export TOOLCHAIN=$PWD/android-toolchain | ||
mkdir -p $TOOLCHAIN | ||
$1/build/tools/make-standalone-toolchain.sh \ | ||
--toolchain=arm-linux-androideabi-4.9 \ | ||
--arch=arm \ | ||
--toolchain=$TOOLCHAIN_NAME-$CC_VER \ | ||
--arch=$ARCH \ | ||
--install-dir=$TOOLCHAIN \ | ||
--platform=android-21 | ||
export PATH=$TOOLCHAIN/bin:$PATH | ||
export AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar | ||
export CC=$TOOLCHAIN/bin/arm-linux-androideabi-gcc | ||
export CXX=$TOOLCHAIN/bin/arm-linux-androideabi-g++ | ||
export LINK=$TOOLCHAIN/bin/arm-linux-androideabi-g++ | ||
export AR=$TOOLCHAIN/bin/$SUFFIX-ar | ||
export CC=$TOOLCHAIN/bin/$SUFFIX-gcc | ||
export CXX=$TOOLCHAIN/bin/$SUFFIX-g++ | ||
export LINK=$TOOLCHAIN/bin/$SUFFIX-g++ | ||
|
||
./configure \ | ||
--dest-cpu=arm \ | ||
--dest-os=android | ||
--dest-cpu=$DEST_CPU \ | ||
--dest-os=android \ | ||
--without-snapshot \ | ||
--openssl-no-asm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
method: ['swap16', 'swap32', 'htons', 'htonl'], | ||
len: [4, 64, 512, 768, 1024, 1536, 2056, 4096, 8192], | ||
n: [1e6] | ||
}); | ||
|
||
// The htons and htonl methods below are used to benchmark the | ||
// performance difference between doing the byteswap in pure | ||
// javascript regardless of Buffer size as opposed to dropping | ||
// down to the native layer for larger Buffer sizes. | ||
|
||
Buffer.prototype.htons = function htons() { | ||
if (this.length % 2 !== 0) | ||
throw new RangeError(); | ||
for (var i = 0, n = 0; i < this.length; i += 2) { | ||
n = this[i]; | ||
this[i] = this[i + 1]; | ||
this[i + 1] = n; | ||
} | ||
return this; | ||
}; | ||
|
||
Buffer.prototype.htonl = function htonl() { | ||
if (this.length % 2 !== 0) | ||
throw new RangeError(); | ||
for (var i = 0, n = 0; i < this.length; i += 4) { | ||
n = this[i]; | ||
this[i] = this[i + 3]; | ||
this[i + 3] = n; | ||
n = this[i + 1]; | ||
this[i + 1] = this[i + 2]; | ||
this[i + 2] = n; | ||
} | ||
return this; | ||
}; | ||
|
||
function createBuffer(len) { | ||
const buf = Buffer.allocUnsafe(len); | ||
for (var i = 1; i <= len; i++) | ||
buf[i - 1] = i; | ||
return buf; | ||
} | ||
|
||
function bufferSwap(n, buf, method) { | ||
for (var i = 1; i <= n; i++) | ||
buf[method](); | ||
} | ||
|
||
function main(conf) { | ||
const method = conf.method; | ||
const len = conf.len | 0; | ||
const n = conf.n | 0; | ||
const buf = createBuffer(len); | ||
bench.start(); | ||
bufferSwap(n, buf, method); | ||
bench.end(n); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
millions: [5] | ||
}); | ||
|
||
function main(conf) { | ||
const N = +conf.millions * 1e6; | ||
|
||
process.on('exit', function() { | ||
bench.end(N / 1e6); | ||
}); | ||
|
||
function cb1(arg1) {} | ||
function cb2(arg1, arg2) {} | ||
function cb3(arg1, arg2, arg3) {} | ||
|
||
bench.start(); | ||
for (let i = 0; i < N; i++) { | ||
if (i % 3 === 0) | ||
setImmediate(cb3, 512, true, null); | ||
else if (i % 2 === 0) | ||
setImmediate(cb2, false, 5.1); | ||
else | ||
setImmediate(cb1, 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
millions: [10] | ||
}); | ||
|
||
function main(conf) { | ||
const N = +conf.millions * 1e6; | ||
|
||
process.on('exit', function() { | ||
bench.end(N / 1e6); | ||
}); | ||
|
||
function cb() {} | ||
|
||
bench.start(); | ||
for (let i = 0; i < N; i++) { | ||
setImmediate(cb); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
millions: [10] | ||
}); | ||
|
||
function main(conf) { | ||
const N = +conf.millions * 1e6; | ||
|
||
process.on('exit', function() { | ||
bench.end(N / 1e6); | ||
}); | ||
|
||
function cb3(n, arg2, arg3) { | ||
if (--n) { | ||
if (n % 3 === 0) | ||
setImmediate(cb3, n, true, null); | ||
else if (n % 2 === 0) | ||
setImmediate(cb2, n, 5.1); | ||
else | ||
setImmediate(cb1, n); | ||
} | ||
} | ||
function cb2(n, arg2) { | ||
if (--n) { | ||
if (n % 3 === 0) | ||
setImmediate(cb3, n, true, null); | ||
else if (n % 2 === 0) | ||
setImmediate(cb2, n, 5.1); | ||
else | ||
setImmediate(cb1, n); | ||
} | ||
} | ||
function cb1(n) { | ||
if (--n) { | ||
if (n % 3 === 0) | ||
setImmediate(cb3, n, true, null); | ||
else if (n % 2 === 0) | ||
setImmediate(cb2, n, 5.1); | ||
else | ||
setImmediate(cb1, n); | ||
} | ||
} | ||
bench.start(); | ||
setImmediate(cb1, N); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
'use strict'; | ||
|
||
const common = require('../common.js'); | ||
const bench = common.createBenchmark(main, { | ||
millions: [10] | ||
}); | ||
|
||
function main(conf) { | ||
const N = +conf.millions * 1e6; | ||
let n = N; | ||
|
||
process.on('exit', function() { | ||
bench.end(N / 1e6); | ||
}); | ||
|
||
bench.start(); | ||
setImmediate(onNextTick); | ||
function onNextTick() { | ||
if (--n) | ||
setImmediate(onNextTick); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.