Created
June 8, 2025 18:59
-
-
Save misu200/7bc269af5dbf8b755059ad5822a7a970 to your computer and use it in GitHub Desktop.
wp_remote_post speed test
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
| <?php | |
| // Usage: wp eval-file test-wp-remote-post.php [blog_id] | |
| // Get the blog ID from command line arguments (default to 1 if not provided) | |
| require_once( dirname( __FILE__ ) . '/wp-load.php' ); | |
| //$url = site_url('wp-admin/admin-ajax.php?action=task_runner_preload-urls'); | |
| $url = "https://ipify.org"; | |
| $args = [ | |
| 'timeout' => 0.1, | |
| 'blocking' => false, | |
| 'sslverify' => false, | |
| ]; | |
| $start = microtime(true); | |
| $response = wp_remote_post($url, $args); | |
| $end = microtime(true); | |
| $exec_time = $end - $start; | |
| $output .= "AJAX URL: $url" . PHP_EOL; | |
| $output .= "HTTP Status: " . wp_remote_retrieve_response_code($response) . PHP_EOL; | |
| $output .= "Execution Time: " . round($exec_time, 4) . " seconds" . PHP_EOL; | |
| $output .= "Response Body (truncated):" . PHP_EOL; | |
| $output .= substr(wp_remote_retrieve_body($response), 0, 500) . PHP_EOL; | |
| echo '<pre>' . htmlspecialchars($output) . '</pre>'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note: If using
wp eval-filethere's no need for this line: