<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("");
for (var i=0; i < 10000; i++) {
document.write("Concatenation with plus: "
+ (d2.getTime() - d1.getTime()) + " milliseconds");
var buffer = new StringBuffer();
for (var i=0; i < 10000; i++) {
var result = buffer.toString();
document.write("<br />Concatenation with StringBuffer: "
+ (d2.getTime() - d1.getTime()) + " milliseconds");