Crazy Blazin' DOM Injection
About 200 ms
function mark() {
  var t = 0, tp = '';
  var c = [], i = { r: 0, p: '', c: 0 };
  var elements = document.body.getElementsByTagName('*');
  var length = elements.length, index, v;
  for (index = 0; index &lt; length; ++index) {
    v = elements[index];
    switch (v.tagName) {
      case 'TH':
      case 'TD':
        v.className = i.p + i.c++;
        if (i.c == 10 &amp;&amp; i.r == 10) {
          i = c.pop();
        }
        continue;
      case 'TR':
        v.className = i.p = i.t + i.r++;
        i.c = 0;
        i.p += '-col-';
        continue;
      case 'TABLE':
        v.className = tp = 'table-' + t++;
        tp += '-row-';
        c.push(i);
        i = { t: tp, r: 0, p: '', c: 0 };
    }
  }
}

If your code runs more than 2s, you must do something wrong. I believe.