Update vendors.

Former-commit-id: 44c2fe9fbfbf50aa64663d46b45d6fd2c778f2b7
This commit is contained in:
John-David Dalton
2012-08-16 21:20:54 -07:00
parent 79fbade92a
commit feff34b021
6 changed files with 98 additions and 64 deletions

View File

@@ -2,19 +2,19 @@
A [robust](http://calendar.perfplanet.com/2010/bulletproof-javascript-benchmarks/ "Bulletproof JavaScript benchmarks") benchmarking library that works on nearly all JavaScript platforms<sup><a name="fnref1" href="#fn1">1</a></sup>, supports high-resolution timers, and returns statistically significant results. As seen on [jsPerf](http://jsperf.com/).
## BestieJS
## Download
Benchmark.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.
* [Development source](https://raw.github.com/bestiejs/benchmark.js/1.0.0/benchmark.js)
## Documentation
## Dive in
The documentation for Benchmark.js can be viewed here: <http://benchmarkjs.com/docs>
Weve got [API docs](http://benchmarkjs.com/docs) and [unit tests](http://benchmarkjs.com/tests).
For a list of upcoming features, check out our [roadmap](https://github.com/bestiejs/benchmark.js/wiki/Roadmap).
## Support
Benchmark.js has been tested in at least Adobe AIR 2.6, Chrome 5-21, Firefox 1.5-13, IE 6-9, Opera 9.25-12.01, Safari 3-6, Node.js 0.4.8-0.8.6, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC3.
Benchmark.js has been tested in at least Adobe AIR 3.1, Chrome 5-21, Firefox 1.5-13, IE 6-9, Opera 9.25-12.01, Safari 3-6, Node.js 0.8.6, Narwhal 0.3.2, RingoJS 0.8, and Rhino 1.7RC5.
## Installation and usage
@@ -118,6 +118,10 @@ suite.add('RegExp#test', function() {
// > Fastest is String#indexOf
~~~
## BestieJS
Benchmark.js is part of the BestieJS *"Best in Class"* module collection. This means we promote solid browser/environment support, ES5 precedents, unit testing, and plenty of documentation.
## Authors
* [Mathias Bynens](http://mathiasbynens.be/)

View File

@@ -244,6 +244,36 @@
} catch(e) {
support.getAllKeys = false;
}
/**
* Detect if own properties are iterated before inherited properties (all but IE < 9).
*
* @name iteratesOwnLast
* @memberOf Benchmark.support
* @type Boolean
*/
support.iteratesOwnFirst = (function() {
var props = [];
function ctor() { this.x = 1; }
ctor.prototype = { 'y': 1 };
for (var prop in new ctor) { props.push(prop); }
return props[0] == 'x';
}());
/**
* Detect if a node's [[Class]] is resolvable (all but IE < 9)
* and that the JS engine errors when attempting to coerce an object to a
* string without a `toString` property value of `typeof` "function".
*
* @name nodeClass
* @memberOf Benchmark.support
* @type Boolean
*/
try {
support.nodeClass = ({ 'toString': 0 } + '', toString.call(doc || 0) != '[object Object]');
} catch(e) {
support.nodeClass = true;
}
}());
/**
@@ -583,14 +613,17 @@
while (++index < length) {
if ((index - start) in tail) {
object[index] = tail[index - start];
} else {
} else if (index in object) {
delete object[index];
}
}
// delete excess elements
deleteCount = deleteCount > elementCount ? deleteCount - elementCount : 0;
while (deleteCount--) {
delete object[length + deleteCount];
index = length + deleteCount;
if (index in object) {
delete object[index];
}
}
object.length = length;
return result;
@@ -941,7 +974,13 @@
// escape the `{` for Firefox 1
result = (/^[^{]+\{([\s\S]*)}\s*$/.exec(fn) || 0)[1];
}
return (result || '').replace(/^\s+|\s+$/g, '');
// trim string
result = (result || '').replace(/^\s+|\s+$/g, '');
// detect strings containing only the "use strict" directive
return /^(?:\/\*+[\w|\W]*?\*\/|\/\/.*?[\n\r\u2028\u2029]|\s)*(["'])use strict\1;?$/.test(result)
? ''
: result;
}
/**
@@ -994,36 +1033,43 @@
}
/**
* Checks if the specified `value` is an object created by the `Object`
* constructor assuming objects created by the `Object` constructor have no
* inherited enumerable properties and assuming there are no `Object.prototype`
* extensions.
* Checks if a given `value` is an object created by the `Object` constructor
* assuming objects created by the `Object` constructor have no inherited
* enumerable properties and that there are no `Object.prototype` extensions.
*
* @private
* @param {Mixed} value The value to check.
* @returns {Boolean} Returns `true` if `value` is an object, else `false`.
* @returns {Boolean} Returns `true` if the `value` is a plain `Object` object, else `false`.
*/
function isObject(value) {
var ctor,
result = !!value && toString.call(value) == '[object Object]';
if (result && noArgumentsClass) {
// avoid false positives for `arguments` objects in IE < 9
result = !isArguments(value);
function isPlainObject(value) {
// avoid non-objects and false positives for `arguments` objects in IE < 9
var result = false;
if (!(value && typeof value == 'object') || (noArgumentsClass && isArguments(value))) {
return result;
}
if (result) {
// IE < 9 presents nodes like `Object` objects:
// IE < 8 are missing the node's constructor property
// IE 8 node constructors are typeof "object"
ctor = value.constructor;
// check if the constructor is `Object` as `Object instanceof Object` is `true`
if ((result = isClassOf(ctor, 'Function') && ctor instanceof ctor)) {
// An object's own properties are iterated before inherited properties.
// If the last iterated key belongs to an object's own property then
// there are no inherited enumerable properties.
forProps(value, function(subValue, subKey) { result = subKey; });
result = result === true || hasKey(value, result);
// IE < 9 presents DOM nodes as `Object` objects except they have `toString`
// methods that are `typeof` "string" and still can coerce nodes to strings.
// Also check that the constructor is `Object` (i.e. `Object instanceof Object`)
var ctor = value.constructor;
if ((support.nodeClass || !(typeof value.toString != 'function' && typeof (value + '') == 'string')) &&
(!isClassOf(ctor, 'Function') || ctor instanceof ctor)) {
// In most environments an object's own properties are iterated before
// its inherited properties. If the last iterated property is an object's
// own property then there are no inherited enumerable properties.
if (support.iteratesOwnFirst) {
forProps(value, function(subValue, subKey) {
result = subKey;
});
return result === false || hasKey(value, result);
}
// IE < 9 iterates inherited properties before own properties. If the first
// iterated property is an object's own property then there are no inherited
// enumerable properties.
forProps(value, function(subValue, subKey) {
result = !hasKey(value, subKey);
return false;
});
return result === false;
}
return result;
}
@@ -1265,7 +1311,7 @@
break;
case '[object Object]':
isObject(value) && (clone = new ctor);
isPlainObject(value) && (clone = {});
break;
case '[object Number]':
@@ -2405,7 +2451,7 @@
var source = {
'setup': getSource(bench.setup, preprocess('m$.setup()')),
'fn': getSource(fn, preprocess('f$(' + fnArg + ')')),
'fn': getSource(fn, preprocess('m$.fn(' + fnArg + ')')),
'fnArg': fnArg,
'teardown': getSource(bench.teardown, preprocess('m$.teardown()'))
};
@@ -3045,6 +3091,7 @@
/**
* The maximum time a benchmark is allowed to run before finishing (secs).
*
* Note: Cycle delays aren't counted toward the maximum time.
*
* @memberOf Benchmark.options