function generateTableData() {
var returnArray = [];
for (var i = 0; i < 5; i++) {
var tempObj = {};
var dateTime = new Date();
tempObj.Time = dateTime.getHours()+":"+dateTime.getMinutes();
tempObj.Type = "Test Type";
tempObj.ProcessId = "Test Proc";
tempObj.Module = "Test Module";
tempObj.Description = "This is the description";
returnArray[i] = tempObj;
}
return returnArray;
};
function populateTable(event) {
var t0 = performance.now();
var tableData = generateTableData();
var t1 = performance.now();
console.info("Time taken to generate table data = %d ms",(t1-t0));
var dataLength = tableData.length;
var table = document.getElementById("testTable");
var t0 = performance.now();
for (var i = 0; i < dataLength; i++) {
var row = table.insertRow(-1);
// Initially have to pass as an argument howmany columns required, can be handled.
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
var cell4 = row.insertCell(3);
var cell5 = row.insertCell(4);
var cell6 = row.insertCell(5);
cell1.innerHTML = i;
cell2.innerHTML = tableData[i].Time;
cell3.innerHTML = tableData[i].Type;
cell4.innerHTML = tableData[i].ProcessId;
cell5.innerHTML = tableData[i].Module;
cell6.innerHTML = tableData[i].Description;
}
var t1 = performance.now();
console.info("Time taken to populate %d records in to the table data = %d ms",dataLength, (t1-t0));
};
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.