We're using jQuery for selection DOM elements and the speed of this has seriouly degraded in Prince 8.1 (compared to Prince 8.0). I've tracked this down to jQuery converting a NodeList to an array by using Array.prototype.slice (see http://code.jquery.com/jquery-1.7.2.js, line 4855). This is much slower in Prince 8.1 than in Prince 8.0.
I've cooked up a pseudo scientific experiment for illustrating the performance issue (see attachment or test file below) and plotted the results in a couple of graphs [https://docs.google.com/spreadsheet/ccc?key=0Ap5BG-Ya1spxdHFIVTNGV05aaTAySG9ZY2pJVDRpOXc#gid=0].
The tests have been performed using the Mac version of Prince 8.0 and 8.1.
Best regards,
Mikkel
I've cooked up a pseudo scientific experiment for illustrating the performance issue (see attachment or test file below) and plotted the results in a couple of graphs [https://docs.google.com/spreadsheet/ccc?key=0Ap5BG-Ya1spxdHFIVTNGV05aaTAySG9ZY2pJVDRpOXc#gid=0].
The tests have been performed using the Mac version of Prince 8.0 and 8.1.
Best regards,
Mikkel
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DOM Speed</title>
</head>
<body>
<pre id="output"></pre>
<script type="text/javascript">/*<![CDATA[*/(function() {
var log = function() {
var args = Array.prototype.slice.call(arguments, 0),
line = args.join('\t'),
container = document.getElementById('output');
if (container.firstChild) {
container.replaceChild(document.createTextNode(container.firstChild.nodeValue+'\n'+line), container.firstChild);
} else {
container.appendChild(document.createTextNode(line));
}
if ((typeof(console) != 'undefined') && (typeof(console.log) == 'function')) {
;;; console.log(line);
}
},
loop, i, elements, starttime, endtime, deltaT;
for (loop = 0; loop < 10; loop++) {
// Create some elements
for (i = 0; i < 100; i++) {
document.body.appendChild(document.createElement('div'));
}
// Select the elements
elements = document.getElementsByTagName('div');
// When using jQuery for selecting elements, a NodeList is converted to an array by using Array.prototype.slice (http://code.jquery.com/jquery-1.7.2.js, line 4855).
// This is extremely slow in Prince 8.1 compared to Prince 8.0
starttime = new Date();
elements = Array.prototype.slice.call(elements, 0);
endtime = new Date();
deltaT = endtime.getTime()-starttime.getTime();
// Log number of elements, time used for getting array of HTMLElement and average time pr. element
;;; log([ elements.length, deltaT, (elements.length > 0) ? (deltaT/elements.length) : '–' ].join('\t'));
}
}());/*]]>*/</script>
</body>
</html>