On 10/10/13 10:28 AM, Axel Hecht wrote:
My point is, the perf was completely abysmal, and the key is to use
nsINodeInfo for the xpath patterns instead of DOM localName and
namespaceURI string comparisons.

This may still be an issue, though I wouldn't be surprised if the speed of .localName in JS nowadays (about 40ns on modern hardware, looks like[1]) is faster than the XPCOM GetLocalName was back in the day. That says nothing about speed of the string compares, of course...

-Boris

[1] Testcase, but you'll have to disable the CSE/loop-hoisting optimization we have for .localName to get useful numbers out:

<!DOCTYPE html>
<script>
  var div = document.createElement("div");
  var span = document.createElement("span");
  var count = 1000000;
  var start = new Date;
  for (var i = 0; i < count; ++i) {
    // Switch back and forth between two elements to defeat
    // the external string cache
    div.localName;
    span.localName;
  }
  var stop = new Date;
  alert((stop - start) / count * 1e6);
</script>

For scale, on the same hardware I get about 40ns per get in a modern nightly and 3600ns per get in Firefox 2. Times have changed a bit since then.
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to