boardgenerating

JavaScript performance comparison

Revision 2 of this test case created by mgibsonbr

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
t1
var wid = 10;
var hei = 6;
var len = (wid * hei);
var map = "005000200000000008000600000006000700000040000000500030400000".split("");

var str = "<table id=\"board\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr>";

for (var i = 0; i < len; i++) {
  if (i && !(i % wid)) {
    str += "</tr><tr>";
  }
  str += "<td>" + ((map[i] != 0) ? map[i] : "&nbsp;") + "</td>";
}

str += "</tr></tbody></table>";

var x = str;
pending…
t2
var map = "0050002000-0000000800-0600000006-0007000000-4000000050-0030400000".split("").join("</td><td>").replace(/<td>-<\/td>/g, "</tr><tr>").replace(/0/g, "&nbsp;");

var str = "<table id=\"board\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr><td>" + map + "</td></tr></tbody></table>";

var x = str;
pending…
t3
var map = ["0050002000", "0000000800", "0600000006", "0007000000", "4000000050", "0030400000"].join('-').split("").join("</td><td>").replace(/<td>-<\/td>/g, "</tr><tr>").replace(/0/g, "&nbsp;");

var str = "<table id=\"board\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr><td>" + map + "</td></tr></tbody></table>";

var x = str;
pending…
t4
var wid = 10;
var hei = 6;
var len = (wid * hei);
var map = "005000200000000008000600000006000700000040000000500030400000".split("");

var str = ["<table id=\"board\" cellpadding=\"0\" cellspacing=\"0\"><tbody><tr>"];

for (var i = 0; i < len; i++) {
  if (i && !(i % wid)) {
    str.push("</tr><tr>");
  }
  str.push("<td>");
  str.push((map[i] != 0) ? map[i] : "&nbsp;");
  str.push("</td>");
}

str.push("</tr></tbody></table>");

var x = str.join("");
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment