Skip to content

Instantly share code, notes, and snippets.

@xk
Created February 16, 2011 12:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xk/829279 to your computer and use it in GitHub Desktop.
Save xk/829279 to your computer and use it in GitHub Desktop.
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