Skip to content

Instantly share code, notes, and snippets.

@blatyo
Created September 2, 2009 15:21
Show Gist options
  • Select an option

  • Save blatyo/179759 to your computer and use it in GitHub Desktop.

Select an option

Save blatyo/179759 to your computer and use it in GitHub Desktop.
/* This tests my array union, with the one used in prototype 1.6.1 */
Array.prototype.union = function(otherArray){
return this.without.apply(this, this.without.apply(this, otherArray));
}
var a = [1,2,3,4,5,6,7,8,9,0];
var b = [10, 9, 7, 6, 5, 4, 48, 32, 11];
var test = function(){
console.log("Testing Union");
console.log(new Date());
(1000).times(function(){
a.union(b);
});
console.log(new Date());
console.log("Testing Intersect");
console.log(new Date());
(1000).times(function(){
a.intersect(b);
});
console.log(new Date());
};
test();
/*Results
Testing Union
Wed Sep 02 2009 11:18:04 GMT-0400 (EST)
Wed Sep 02 2009 11:18:05 GMT-0400 (EST)
Testing Intersect
Wed Sep 02 2009 11:18:05 GMT-0400 (EST)
Wed Sep 02 2009 11:18:08 GMT-0400 (EST)
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment