Timing statement
|
|
<html> <head> <title>Example</title> </head> <body> <script type="text/javascript"> function StringBuffer() { this.__strings__ = new Array; }
StringBuffer.prototype.append = function (str) { this.__strings__.push(str); };
StringBuffer.prototype.toString = function () { return this.__strings__.join(""); };
var buffer = new StringBuffer(); var d1 = new Date();
for (var i=0; i < 10000; i++) { buffer.append("text"); } var result = buffer.toString();
var d2 = new Date();
document.write("Concatenation with StringBuffer: " + (d2.getTime() - d1.getTime()) + " milliseconds");
</script>
</body> </html>
|
|
|
HTML code for linking to this page:
|