utc time to readable string conversion

Benchmark created on


Setup

var a=Math.round(Math.random()*1e9);


function time_utc_iso_int(s)
	{
	//return new Date(s*1000).toISOString();
	var a=new Date(s*1000);
	return a.getUTCFullYear()*10000000000
	+(1+a.getUTCMonth())*100000000
	+a.getUTCDate()*1000000
	+a.getUTCHours()*10000 
	+a.getUTCMinutes()*100
	+a.getUTCSeconds();
	}
function time_utc_iso(s)
	{
	//return new Date(s*1000).toISOString();
	var a=new Date(s*1000);
	return a.getUTCFullYear()+"-"+(1+a.getUTCMonth())+"-"+(a.getUTCDate())+" "+
		(a.getUTCHours())+":"+(a.getUTCMinutes())+":"+(a.getUTCSeconds());
	}
function time_utc_iso_fake(s)
	{
	//return new Date(s*1000).toISOString();
	var a=new Date(s*1000);
	return "sdsds"+"-"+(1+Math.random())+"-"+(Math.random())+" "+
		(Math.random())+":"+(Math.random())+":"+(Math.random());
	}

Test runner

Ready to run.

Testing in
TestOps/sec
toISOString
var c=new Date(a).toISOString();
ready
DIY
var c=time_utc_iso(a);
ready
string addition
var c=time_utc_iso_fake(a);
ready
integer
var c=time_utc_iso_int(a);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.