-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6e469b6
commit f03fa2d
Showing
3 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,183 @@ | ||
<?php | ||
|
||
/* | ||
* phpcs:disable PSR1.Files.SideEffects | ||
* phpcs:disable PSR1.Classes.ClassDeclaration.MissingNamespace | ||
*/ | ||
|
||
define('ABSPATH', dirname(__DIR__, 1)); | ||
define('HOUR_IN_SECONDS', 3600); | ||
|
||
$options = []; | ||
$hooks = []; | ||
|
||
function is_admin() | ||
{ | ||
return false; | ||
} | ||
|
||
function add_action($hook, $callback, $c = 10, $d = 1) | ||
{ | ||
global $hooks; | ||
$hooks[$hook] ??= []; | ||
$hooks[$hook][] = $callback; | ||
} | ||
|
||
function do_action($hook, ...$args) | ||
{ | ||
global $hooks; | ||
$actions = $hooks[$hook] ?? []; | ||
foreach ($actions as $a) { | ||
$a(); | ||
} | ||
} | ||
|
||
function add_filter($hook, $callback, $c = 10, $d = 1) | ||
{ | ||
add_action($hook, $callback, $c, $d); | ||
} | ||
|
||
function apply_filters($hook, $value, $prio = 10, $args = 2) | ||
{ | ||
global $hooks; | ||
|
||
$filters = $hooks[$hook] ?? []; | ||
foreach ($filters as $cb) { | ||
$value = $cb($value); | ||
} | ||
|
||
return $value; | ||
} | ||
|
||
function add_shortcode($a, $b) | ||
{ | ||
} | ||
|
||
function number_format_i18n($number, $decimals = 0) | ||
{ | ||
return number_format($number, $decimals); | ||
} | ||
|
||
function register_activation_hook($file, $callback) | ||
{ | ||
} | ||
|
||
function register_deactivation_hook($file, $callback) | ||
{ | ||
} | ||
|
||
function update_option($option_name, $value, $autoload = false) | ||
{ | ||
global $options; | ||
$options[$option_name] = $value; | ||
} | ||
|
||
function get_option($option_name, $default = null) | ||
{ | ||
global $options; | ||
return $options[$option_name] ?? $default; | ||
} | ||
|
||
function get_transient($name) | ||
{ | ||
return null; | ||
} | ||
|
||
function set_transient($name, $value, $ttl) | ||
{ | ||
} | ||
|
||
function delete_transient($name) | ||
{ | ||
} | ||
|
||
function get_role($role) | ||
{ | ||
return null; | ||
} | ||
|
||
function get_site_url() | ||
{ | ||
return ''; | ||
} | ||
|
||
function site_url() | ||
{ | ||
return ''; | ||
} | ||
|
||
function is_multisite() | ||
{ | ||
return false; | ||
} | ||
|
||
function wp_next_scheduled($event) | ||
{ | ||
return false; | ||
} | ||
|
||
function wp_schedule_event($timestamp, $recurrence, $hook, $args = []) | ||
{ | ||
} | ||
|
||
function wp_upload_dir() | ||
{ | ||
return [ | ||
'basedir' => '/tmp', | ||
]; | ||
} | ||
|
||
function wp_remote_get($url) | ||
{ | ||
return null; | ||
} | ||
|
||
function wp_remote_retrieve_response_code($response) | ||
{ | ||
return ''; | ||
} | ||
|
||
function wp_remote_retrieve_headers($response) | ||
{ | ||
return []; | ||
} | ||
|
||
function is_wp_error($thing) | ||
{ | ||
return false; | ||
} | ||
|
||
function __($string, $text_domain) | ||
{ | ||
return $string; | ||
} | ||
|
||
function register_post_type($name, $args) | ||
{ | ||
} | ||
|
||
function wp_register_script($handle, $src, $deps = [], $version = '') | ||
{ | ||
} | ||
|
||
function plugins_url($file, $path) | ||
{ | ||
return $path; | ||
} | ||
|
||
class wpdb_mock | ||
{ | ||
public $prefix = ''; | ||
public function query($sql) | ||
{ | ||
return null; | ||
} | ||
|
||
public function prepare($query, ...$params) | ||
{ | ||
return $query; | ||
} | ||
} | ||
|
||
global $wpdb; | ||
$wpdb = new wpdb_mock(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
require __DIR__ . '/benchmark-mocks.php'; | ||
|
||
// make sure we're not running through all migrations | ||
update_option('mc4wp_version', '999.1.1'); | ||
|
||
$memory = memory_get_usage(); | ||
$time_start = microtime(true); | ||
|
||
require dirname(__DIR__, 1) . '/mailchimp-for-wp.php'; | ||
|
||
do_action('plugins_loaded'); | ||
do_action('setup_theme'); | ||
do_action('after_setup_theme'); | ||
do_action('init'); | ||
do_action('wp_loaded'); | ||
|
||
$time = round((microtime(true) - $time_start) * 1000, 2); | ||
$memory_used = (memory_get_usage() - $memory) >> 10; | ||
|
||
echo "Memory: $memory_used KB\n"; | ||
echo "Time: $time ms\n"; |