Skip to content

Instantly share code, notes, and snippets.

@PeterBooker
Created October 6, 2018 11:01
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 PeterBooker/d92331a2ac715079849d18c08d4b1ee4 to your computer and use it in GitHub Desktop.
Save PeterBooker/d92331a2ac715079849d18c08d4b1ee4 to your computer and use it in GitHub Desktop.
Health Check Tests Prof
<?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>';
?>
@PeterBooker
Copy link
Author

Initial results:

Running tests with 5 iterations.

Testing: WordPress Version
Average Time: 0 ms

Testing: Plugin Versions
Average Time: 12 ms

Testing: Theme Versions
Average Time: 1 ms

Testing: PHP Version
Average Time: 0 ms

Testing: Database Server version
Average Time: 0 ms

Testing: JSON Extension
Average Time: 0 ms

Testing: MySQL utf8mb4 support
Average Time: 0 ms

Testing: Communication with WordPress.org
Average Time: 540 ms

Testing: HTTPS status
Average Time: 0 ms

Testing: Secure communication
Average Time: 0 ms

Testing: Scheduled events
Average Time: 2 ms

Testing: Background updates
Average Time: 2135 ms

Testing: Loopback request
Average Time: 3363 ms

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment