<?php
/********** Generating array (because use of range() was to simple :)): *************/
function generateSortedArray( $start = 300000 , $elementsNum = 10000 , $dev = 30 ) {
for ( $i = 1 ; $i <= $elementsNum ; $i ++ ) {
$start -= $rand ;
$arr [ ] = $start ;
}
return $arr ;
}
/********************** Four insert functions: **************************/
// for loop, and array copying
function insert1( & $arr , $elem ) {
$arr [ ] = $elem ;
return true ;
}
$lastIndex = $c - 1 ;
$inserted = false ;
for ( $i = 0 ; $i < $c ; $i ++ ) {
if ( ! $inserted && $arr [ $i ] <= $elem ) {
$tmp [ ] = $elem ;
$inserted = true ;
}
$tmp [ ] = $arr [ $i ] ;
if ( $lastIndex == $i && ! $inserted ) $tmp [ ] = $elem ;
}
$arr = $tmp ;
return true ;
}
// new element inserted at the end of array
// and moved up until correct place
function insert2( & $arr , $elem ) {
for ( $i = $c ; $i > 0 ; $i -- ) {
if ( $arr [ $i - 1 ] >= $arr [ $i ] ) break ;
$tmp = $arr [ $i - 1 ] ;
$arr [ $i - 1 ] = $arr [ $i ] ;
$arr [ $i ] = $tmp ;
}
return true ;
}
// binary search for correct place + array_splice() to insert element
function insert3( & $arr , $elem ) {
$startIndex = 0 ;
$stopIndex = count ( $arr ) - 1 ; $middle = 0 ;
while ( $startIndex < $stopIndex ) {
$middle = ceil ( ( $stopIndex + $startIndex ) / 2 ) ; if ( $elem > $arr [ $middle ] ) {
$stopIndex = $middle - 1 ;
} else if ( $elem <= $arr [ $middle ] ) {
$startIndex = $middle ;
}
}
$offset = $elem >= $arr [ $startIndex ] ? $startIndex : $startIndex + 1 ;
}
// for loop to find correct place + array_splice() to insert
function insert4( & $arr , $elem ) {
$inserted = false ;
for ( $i = 0 ; $i < $c ; $i ++ ) {
if ( $elem >= $arr [ $i ] ) {
$inserted = true ;
break ;
}
}
if ( ! $inserted ) $arr [ ] = $elem ;
return true ;
}
/*********************** Speed tests: *************************/
// check if array is sorted descending
function checkIfArrayCorrect( $arr , $expectedCount = null ) {
if ( isset ( $expectedCount ) && $c != $expectedCount ) return false ; $correct = true ;
for ( $i = 0 ; $i < $c - 1 ; $i ++ ) {
if ( ! isset ( $arr [ $i + 1 ] ) || $arr [ $i ] < $arr [ $i + 1 ] ) { $correct = false ;
break ;
}
}
return $correct ;
}
// claculates microtimetime diff
function timeDiff( $startTime ) {
return $diff ;
}
// prints formatted execution time info
function showTime( $func , $time ) {
printf ( "Execution time of %s (): %01.7f s\n " , $func , $time ) ; }
// generated elements num
$elementsNum = 10000 ;
// generate starting point
$start = 300000 ;
// generated elements random range 1 - $dev
$dev = 50 ;
echo "Generating array with descending order, $elementsNum elements, begining from $start \n " ;
$arr = generateSortedArray( $start , $elementsNum , $dev ) ;
showTime( 'generateSortedArray' , timeDiff( $startTime ) ) ;
$step = 2 ;
echo "Generating second array using range range(), $elementsNum elements, begining from $start , step $step \n " ;
$arr2 = range ( $start , $start - $elementsNum * $step , $step ) ; showTime( 'range' , timeDiff( $startTime ) ) ;
echo "Checking if array is correct\n " ;
$sorted = checkIfArrayCorrect( $arr , $elementsNum ) ;
showTime( 'checkIfArrayCorrect' , timeDiff( $startTime ) ) ;
if ( ! $sorted ) die ( "Array is not in descending order!\n " ) ; echo "Array OK\n " ;
// number of elements to insert from every range
$randElementNum = 20 ;
// some ranges of elements to insert near begining, middle and end of generated array
// start value => end value
300000 => 280000 ,
160000 => 140000 ,
30000 => 0 ,
) ;
foreach ( $ranges as $from => $to ) {
echo "Generating $randElementNum random elements from range [$from - $to ] to insert\n " ;
while ( count ( $values ) < $randElementNum ) { }
}
// some elements to insert on begining and end of array
echo "Generated elements: \n " ;
for ( $i = 0 ; $i < count ( $toInsert ) ; $i ++ ) { if ( $i > 0 && $i % 5 == 0 ) echo "\n " ;
printf ( "%8d , " , $toInsert [ $i ] ) ; if ( $i == count ( $toInsert ) - 1 ) echo "\n " ; }
// functions to test
$toTest = array ( 'insert1' => null , 'insert2' => null , 'insert3' => null , 'insert4' => null ) ; foreach ( $toTest as $func => & $time ) {
echo "\n \n ================== Testing speed of $func () ======================\n \n " ;
$tmpArr = $arr ;
for ( $i = 0 ; $i < count ( $toInsert ) ; $i ++ ) { $func ( $tmpArr , $toInsert [ $i ] ) ;
}
$time = timeDiff( $startTime , 'checkIfArraySorted' ) ;
showTime( $func , $time ) ;
echo "Checking if after using $func () array is still correct: \n " ;
if ( ! checkIfArrayCorrect
( $tmpArr , count ( $arr ) + count ( $toInsert ) ) ) { echo "Array INCORRECT!\n \n " ;
} else {
echo "Array OK!\n \n " ;
}
echo "Few elements from begining of array:\n " ;
echo "Few elements from end of array:\n " ;
//echo "\n================== Finished testing $func() ======================\n\n";
}
echo "\n \n ================== Functions time summary ======================\n \n " ;
PD9waHAKLyoqKioqKioqKiogR2VuZXJhdGluZyBhcnJheSAoYmVjYXVzZSB1c2Ugb2YgcmFuZ2UoKSB3YXMgdG8gc2ltcGxlIDopKTogKioqKioqKioqKioqKi8KCmZ1bmN0aW9uIGdlbmVyYXRlU29ydGVkQXJyYXkoJHN0YXJ0ID0gMzAwMDAwLCAkZWxlbWVudHNOdW0gPSAxMDAwMCwgJGRldiA9IDMwKXsKCSRhcnIgPSBhcnJheSgpOwoJZm9yKCRpID0gMTsgJGkgPD0gJGVsZW1lbnRzTnVtOyAkaSsrKXsKCQkkcmFuZCA9IG10X3JhbmQoMSwgJGRldik7CgkJJHN0YXJ0IC09ICRyYW5kOwoJCSRhcnJbXSA9ICRzdGFydDsgCgl9CglyZXR1cm4gJGFycjsKfQoKLyoqKioqKioqKioqKioqKioqKioqKiogRm91ciBpbnNlcnQgZnVuY3Rpb25zOiAqKioqKioqKioqKioqKioqKioqKioqKioqKi8KCi8vIGZvciBsb29wLCBhbmQgYXJyYXkgY29weWluZwpmdW5jdGlvbiBpbnNlcnQxKCYkYXJyLCAkZWxlbSl7CglpZihlbXB0eSgkYXJyKSl7CgkJJGFycltdID0gJGVsZW07CgkJcmV0dXJuIHRydWU7Cgl9CgkkYyA9IGNvdW50KCRhcnIpOwoJJGxhc3RJbmRleCA9ICRjIC0gMTs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cGVlZCBvZiAkZnVuYygpID09PT09PT09PT09PT09PT09PT09PT1cblxuIjsKCSR0bXBBcnIgPSAkYXJyOwoJJHN0YXJ0VGltZSA9IG1pY3JvdGltZSh0cnVlKTsKCWZvcigkaSA9IDA7ICRpIDwgY291bnQoJHRvSW5zZXJ0KTsgJGkrKyl7CgkJJGZ1bmMoJHRtcEFyciwgJHRvSW5zZXJ0WyRpXSk7Cgl9CgkkdGltZSA9IHRpbWVEaWZmKCRzdGFydFRpbWUsICdjaGVja0lmQXJyYXlTb3J0ZWQnKTsKCXNob3dUaW1lKCRmdW5jLCAkdGltZSk7CgllY2hvICJDaGVja2luZyBpZiBhZnRlciB1c2luZyAkZnVuYygpIGFycmF5IGlzIHN0aWxsIGNvcnJlY3Q6IFxuIjsKCWlmKCFjaGVja0lmQXJyYXlDb3JyZWN0KCR0bXBBcnIsIGNvdW50KCRhcnIpICsgY291bnQoJHRvSW5zZXJ0KSkpewoJCWVjaG8gIkFycmF5IElOQ09SUkVDVCFcblxuIjsKCX1lbHNlewoJCWVjaG8gIkFycmF5IE9LIVxuXG4iOwoJfQoJZWNobyAiRmV3IGVsZW1lbnRzIGZyb20gYmVnaW5pbmcgb2YgYXJyYXk6XG4iOwoJcHJpbnRfcihhcnJheV9zbGljZSgkdG1wQXJyLCAwLCA1KSk7CgkKCWVjaG8gIkZldyBlbGVtZW50cyBmcm9tIGVuZCBvZiBhcnJheTpcbiI7CglwcmludF9yKGFycmF5X3NsaWNlKCR0bXBBcnIsIC01KSk7CgoJLy9lY2hvICJcbj09PT09PT09PT09PT09PT09PSBGaW5pc2hlZCB0ZXN0aW5nICRmdW5jKCkgPT09PT09PT09PT09PT09PT09PT09PVxuXG4iOwp9CmVjaG8gIlxuXG49PT09PT09PT09PT09PT09PT0gRnVuY3Rpb25zIHRpbWUgc3VtbWFyeSAgPT09PT09PT09PT09PT09PT09PT09PVxuXG4iOwpwcmludF9yKCR0b1Rlc3QpOw==
stdout
Generating array with descending order, 10000 elements, begining from 300000
Execution time of generateSortedArray(): 0.0086179 s
Generating second array using range range(), 10000 elements, begining from 300000, step 2
Execution time of range(): 0.0028510 s
Checking if array is correct
Execution time of checkIfArrayCorrect(): 0.0055759 s
Array OK
Generating 20 random elements from range [300000 - 280000] to insert
Generating 20 random elements from range [160000 - 140000] to insert
Generating 20 random elements from range [30000 - 0] to insert
Generated elements:
290255, 294911, 293677, 286876, 280342,
287995, 293735, 292697, 299842, 284768,
282965, 287219, 297657, 294414, 297306,
281756, 288477, 281002, 285585, 283227,
147570, 142458, 155661, 141752, 141173,
153437, 155050, 141765, 147127, 156783,
150198, 147377, 154378, 159260, 153550,
145251, 148831, 140505, 157355, 150214,
8833, 676, 23598, 4809, 5777,
16089, 5530, 17560, 13849, 622,
23912, 29811, 23176, 13363, 25908,
318, 17577, 22735, 23453, 19592,
310000, -1000,
================== Testing speed of insert1() ======================
Execution time of insert1(): 0.6082120 s
Checking if after using insert1() array is still correct:
Array OK!
Few elements from begining of array:
Array
(
[0] => 310000
[1] => 299985
[2] => 299975
[3] => 299972
[4] => 299924
)
Few elements from end of array:
Array
(
[0] => 4809
[1] => 676
[2] => 622
[3] => 318
[4] => -1000
)
================== Testing speed of insert2() ======================
Execution time of insert2(): 0.2938130 s
Checking if after using insert2() array is still correct:
Array OK!
Few elements from begining of array:
Array
(
[0] => 310000
[1] => 299985
[2] => 299975
[3] => 299972
[4] => 299924
)
Few elements from end of array:
Array
(
[0] => 4809
[1] => 676
[2] => 622
[3] => 318
[4] => -1000
)
================== Testing speed of insert3() ======================
Execution time of insert3(): 0.1914899 s
Checking if after using insert3() array is still correct:
Array OK!
Few elements from begining of array:
Array
(
[0] => 310000
[1] => 299985
[2] => 299975
[3] => 299972
[4] => 299924
)
Few elements from end of array:
Array
(
[0] => 4809
[1] => 676
[2] => 622
[3] => 318
[4] => -1000
)
================== Testing speed of insert4() ======================
Execution time of insert4(): 0.2639391 s
Checking if after using insert4() array is still correct:
Array OK!
Few elements from begining of array:
Array
(
[0] => 310000
[1] => 299985
[2] => 299975
[3] => 299972
[4] => 299924
)
Few elements from end of array:
Array
(
[0] => 4809
[1] => 676
[2] => 622
[3] => 318
[4] => -1000
)
================== Functions time summary ======================
Array
(
[insert1] => 0.608211994171
[insert2] => 0.293812990189
[insert3] => 0.191489934921
[insert4] => 0.263939142227
)