--- /dev/null
+var Benchmark = require('benchmark'),
+ moment = require("./../moment.js"),
+ base = moment('2013-05-25');
+
+module.exports = {
+ name: 'clone',
+ onComplete: function(){console.log('done');},
+ fn: function(){base.clone();},
+ async: true
+};
--- /dev/null
+[
+ {
+ "name": "clone",
+ "timestamp": "Sun Jul 20 2014 23:14:34 GMT-0400 (EDT)",
+ "count": 1925,
+ "cycles": 3,
+ "hz": 34836.98543958899
+ },
+ {
+ "name": "clone",
+ "timestamp": "Sun Jul 20 2014 23:21:33 GMT-0400 (EDT)",
+ "count": 1885,
+ "cycles": 8,
+ "hz": 36659.44586569106
+ },
+ {
+ "name": "clone",
+ "timestamp": "Mon Jul 21 2014 00:50:03 GMT-0400 (EDT)",
+ "count": 11378,
+ "cycles": 4,
+ "hz": 210942.42334154248
+ }
+]
\ No newline at end of file
locales = {},
// moment internal properties
- momentProperties = {
- _isAMomentObject: null,
- _i : null,
- _f : null,
- _l : null,
- _strict : null,
- _tzm : null,
- _isUTC : null,
- _offset : null, // optional. Combine with _isUTC
- _pf : null,
- _locale : null // optional
- },
+ momentProperties = [
+ '_isAMomentObject',
+ '_i',
+ '_f',
+ '_l',
+ '_strict',
+ '_tzm',
+ '_isUTC',
+ '_offset',
+ '_pf',
+ '_locale'
+ ];
// check for nodeJS
hasModule = (typeof module !== 'undefined' && module.exports),
}
// Moment prototype object
- function Moment(config) {
- checkOverflow(config);
- extend(this, config);
+ function Moment(config, skipOverflow) {
+ if (skipOverflow != false) {
+ checkOverflow(config);
+ }
+ copyConfig(this, config);
}
// Duration Constructor
return a;
}
- function cloneMoment(m) {
- var result = {}, i;
- for (i in m) {
- if (m.hasOwnProperty(i) && momentProperties.hasOwnProperty(i)) {
- result[i] = m[i];
- }
+ function copyConfig(to, from) {
+ var i, prop, val;
+
+ for (i in momentProperties) {
+ prop = momentProperties[i];
+ val = from[prop];
+ if (typeof val !== 'undefined') {
+ to[prop] = val;
+ }
}
- return result;
+ to._d = new Date(+from._d);
+
+ return to;
}
function absRound(number) {
}
if (moment.isMoment(input)) {
- config = cloneMoment(input);
+ return new Moment(input, true);
- config._d = new Date(+input._d);
} else if (format) {
if (isArray(format)) {
makeDateFromStringAndArray(config);
"uglify-js": "latest",
"grunt": "latest",
"nodeunit": "latest",
+ "benchmark": "latest",
"grunt-contrib-jshint": "latest",
"grunt-contrib-nodeunit": "latest",
"grunt-contrib-concat": "latest",
"grunt-env": "latest",
"grunt-jscs": "latest",
"grunt-karma": "latest",
+ "grunt-benchmark" : "latest",
"load-grunt-tasks": "latest",
"karma": "latest",
"karma-chrome-launcher": "latest",