Skip to content

Instantly share code, notes, and snippets.

@xk xk/test.js
Created Feb 16, 2011

Embed
What would you like to do?
test.js
function LinkedList() {
this._length = 0;
this._head = null;
this._tail = null;
}
LinkedList.prototype = {
add: function (data){
var node = { data: data, next: null};
if (this._length == 0) {
this._head = node;
this._tail = node;
} else {
this._tail.next = node;
this._tail = node;
}
this._length++;
}
};
var start = Date.now();
var a = new LinkedList();
for (var i = 1; i <= 1e7; i++) {
a.add(i);
}
var end = Date.now();
var log= (function () {
if (typeof console === 'object') {
return function log (txt) {
//nodejs
console.log(txt);
}
}
else {
return function log (txt) {
//JSC
print(txt);
};
}
})();
log(((end - start) / 1000) + ' s');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.