Created
October 6, 2018 11:01
-
-
Save PeterBooker/d92331a2ac715079849d18c08d4b1ee4 to your computer and use it in GitHub Desktop.
Health Check Tests Prof
This file contains 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
<?php | |
echo '<pre>'; | |
$test_list = Health_Check_Site_Status::get_tests(); | |
$tests = array_merge( $tests['direct'], $tests['async'] ); | |
$limit = 5; | |
echo '<br>'; | |
printf( | |
'Running tests with %d iterations.', | |
$limit | |
); | |
foreach ( $tests as $test ) { | |
$results = array(); | |
echo '<br><br>'; | |
printf( | |
'Testing: %s', | |
$test['label'] | |
); | |
$test_function = sprintf( | |
'test_%s', | |
$test['test'] | |
); | |
if ( ! method_exists( $health_check_site_status, $test_function ) || ! is_callable( array( $health_check_site_status, $test_function ) ) ) { | |
echo 'Aborted test, function not found.'; | |
} | |
ob_start(); | |
$output = ob_get_contents(); | |
for ( $i = 0; $i < $limit; $i++ ) { | |
$start_time = microtime( true ); | |
call_user_func( array( $health_check_site_status, $test_function ) ); | |
$end_time = microtime( true ); | |
$results[ i ] = round( ( $end_time - $start_time ) * 1000 ); | |
} | |
ob_end_clean(); | |
$avg = array_sum( $results ) / count( $results ); | |
echo '<br>'; | |
printf( | |
'Average Time: %s ms', | |
$avg | |
); | |
} | |
echo '</pre>'; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Initial results: