{"size": 1525, "ext": "js", "max_stars_repo_path": "test/performance/index.js", "max_stars_repo_name": "wobuaixiatian/datejs", "max_stars_repo_stars_event_min_datetime": "2015-01-07T06:08:42.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T05:25:12.000Z", "max_issues_repo_path": "test/performance/index.js", "max_issues_repo_name": "wobuaixiatian/datejs", "max_issues_repo_issues_event_min_datetime": "2015-03-26T06:27:17.000Z", "max_issues_repo_issues_event_max_datetime": "2020-07-29T19:19:51.000Z", "max_forks_repo_path": "test/performance/index.js", "max_forks_repo_name": "wobuaixiatian/datejs", "max_forks_repo_forks_event_min_datetime": "2015-01-16T03:21:11.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-21T20:53:00.000Z"}
{"max_stars_count": 1758, "max_issues_count": 89, "max_forks_count": 550, "avg_line_length": 39.1025641026, "max_line_length": 107, "alphanum_fraction": 0.577704918}
var benchmark = function( fn ) { 
	var start = new Date(); fn(); var end = new Date(); 
	return end - start; 
};

var micro_benchmark = function( fn ) { 
	var x = 0; for( var i = 0; i < 1000; i++ ) { x+=benchmark(fn); }; return x;
};

var dateBenchmark = function( tests, fn ) {
	var month, day, year; var time = 0;
	for ( var i = 0 ; i < tests ; i++ ) {
		month = Math.round( Math.random() * 11 );
		day = Math.round( Math.random() * 27 ) + 1;
		year = Math.round( Math.random() * 10 ) + 1995;
    var s = month.toString()+'/'+day.toString()+'/'+year.toString();
    time += benchmark( function() { fn(s) } );
	}
	return (Math.round(time/tests*1000));
};

$(document).ready(function() {
	var tests = 250;
	var results = {
		'Native: .parse': dateBenchmark( tests, Date._parse ),
		'Ext: parseDate': dateBenchmark( tests, function(s) { Date.parseDate( s, 'm/d/Y' ); } ),
        'Datejs: .parseExact': dateBenchmark( tests, function(s) { Date.parseExact( s, 'M/d/yyyy' ); } ),		
		'Datejs: .getParseFunction': dateBenchmark( tests, Date.getParseFunction('M/d/yyyy')  ),        
        'Datejs: .parse': dateBenchmark( tests, Date.parse )
	};
	var max = 0; for ( var k in results ) { max = ( max < results[k] ) ? results[k]:max ; }
	var addResult = function(h, r) { $('#chart').append(
		'<div class="bar">' + 
			'<label>'+h+'</label>'+
			'<div class="value" style="width:'+(r/max*(1/3)*100)+'%"></div>' +
			'<div class="display">'+r+' microseconds</div>');
	};
	for ( var k in results ) { addResult( k, results[k]); }
});