Created
August 8, 2016 05:09
-
-
Save anonymous/bfff6543377d436381b569ca6be44fe5 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/yamuju
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
;(function(){ | |
function concatReorderedArray(arr, arr2){ | |
var start = new Date().getTime() ; | |
if( typeof arr === 'undefined' || arr.length < 1 ) { | |
console.warn('First array is empty or doesn\'t not exist.') | |
return false ; | |
} | |
if( typeof arr2 === 'undefined' || arr2.length < 1 ) { | |
console.warn('Second array is empty or doesn\'t not exist.') | |
return false ; | |
} | |
Array.prototype.append = function( array ) { | |
for( var i = 0, len = array.length; i < len; i++) { | |
if(typeof array[i] !== 'undefined'){ | |
this.push(array[i]) ; | |
} | |
} | |
} | |
arr.append(arr2) ; | |
arr = arr.sort( function( item, item2 ) { | |
if (item < item2) { | |
return -1; | |
} | |
if (item > item2) { | |
return 1; | |
} | |
return 0; | |
} ) ; | |
var end = new Date().getTime() ; | |
var time = end - start; | |
console.log(arr); | |
console.log( 'Array size: ' + arr.length) ; | |
console.log( 'Execution time: ' + time + 'ms', start, end ); | |
} | |
function shuffle ( len, range ) { | |
var arr = []; | |
for( var i = 0; i < len; i++ ) { | |
arr.push( Math.floor( ( Math.random() * range ) ) ) ; | |
} | |
return arr; | |
} | |
concatReorderedArray( shuffle( 50000, 50000000 ), shuffle( 899966, 280000000 ) ) | |
})(); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">;(function(){ | |
function concatReorderedArray(arr, arr2){ | |
var start = new Date().getTime() ; | |
if( typeof arr === 'undefined' || arr.length < 1 ) { | |
console.warn('First array is empty or doesn\'t not exist.') | |
return false ; | |
} | |
if( typeof arr2 === 'undefined' || arr2.length < 1 ) { | |
console.warn('Second array is empty or doesn\'t not exist.') | |
return false ; | |
} | |
Array.prototype.append = function( array ) { | |
for( var i = 0, len = array.length; i < len; i++) { | |
if(typeof array[i] !== 'undefined'){ | |
this.push(array[i]) ; | |
} | |
} | |
} | |
arr.append(arr2) ; | |
arr = arr.sort( function( item, item2 ) { | |
if (item < item2) { | |
return -1; | |
} | |
if (item > item2) { | |
return 1; | |
} | |
return 0; | |
} ) ; | |
var end = new Date().getTime() ; | |
var time = end - start; | |
console.log(arr); | |
console.log( 'Array size: ' + arr.length) ; | |
console.log( 'Execution time: ' + time + 'ms', start, end ); | |
} | |
function shuffle ( len, range ) { | |
var arr = []; | |
for( var i = 0; i < len; i++ ) { | |
arr.push( Math.floor( ( Math.random() * range ) ) ) ; | |
} | |
return arr; | |
} | |
concatReorderedArray( shuffle( 50000, 50000000 ), shuffle( 899966, 280000000 ) ) | |
})();</script></body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;(function(){ | |
function concatReorderedArray(arr, arr2){ | |
var start = new Date().getTime() ; | |
if( typeof arr === 'undefined' || arr.length < 1 ) { | |
console.warn('First array is empty or doesn\'t not exist.') | |
return false ; | |
} | |
if( typeof arr2 === 'undefined' || arr2.length < 1 ) { | |
console.warn('Second array is empty or doesn\'t not exist.') | |
return false ; | |
} | |
Array.prototype.append = function( array ) { | |
for( var i = 0, len = array.length; i < len; i++) { | |
if(typeof array[i] !== 'undefined'){ | |
this.push(array[i]) ; | |
} | |
} | |
} | |
arr.append(arr2) ; | |
arr = arr.sort( function( item, item2 ) { | |
if (item < item2) { | |
return -1; | |
} | |
if (item > item2) { | |
return 1; | |
} | |
return 0; | |
} ) ; | |
var end = new Date().getTime() ; | |
var time = end - start; | |
console.log(arr); | |
console.log( 'Array size: ' + arr.length) ; | |
console.log( 'Execution time: ' + time + 'ms', start, end ); | |
} | |
function shuffle ( len, range ) { | |
var arr = []; | |
for( var i = 0; i < len; i++ ) { | |
arr.push( Math.floor( ( Math.random() * range ) ) ) ; | |
} | |
return arr; | |
} | |
concatReorderedArray( shuffle( 50000, 50000000 ), shuffle( 899966, 280000000 ) ) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment