Skip to content

Instantly share code, notes, and snippets.

Created July 21, 2014 21:41
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/d98a46d00d52d40e7dec to your computer and use it in GitHub Desktop.
Save anonymous/d98a46d00d52d40e7dec to your computer and use it in GitHub Desktop.
<?php
/** Bootstrap WordPress */
include('./wp-load.php');
/**
* Generate some random data
*/
$data = array();
$iterations = 10;
$size = 50;
for ($i = 1; $i <= $iterations; $i++) {
$data[$i] = base64_encode(openssl_random_pseudo_bytes($size));
}
/**
* set_theme_mod
*/
$time = -microtime(true);
set_theme_mod('data_full',$data);
for ($i = 1; $i <= $iterations; $i++) {
set_theme_mod( 'data_'.$i, $data[$i] );
}
$set_theme_mod = $time + microtime(true);
/**
* update_option
*/
$time = -microtime(true);
update_option('data_full',$data);
for ($i = 1; $i <= $iterations; $i++) {
update_option( 'data_'.$i, $data[$i] );
}
$update_option = $time + microtime(true);
/**
* get_theme_mod
*/
$time = -microtime(true);
get_theme_mod('data_full',$data);
for ($i = 1; $i <= $iterations; $i++) {
get_theme_mod( 'data_'.$i );
}
$get_theme_mod = $time + microtime(true);
/**
* get_option
*/
$time = -microtime(true);
get_option('data_full',$data);
for ($i = 1; $i <= $iterations; $i++) {
get_option( 'data_'.$i );
}
$get_option = $time + microtime(true);
?>
<html>
<head>
<title>Test</title>
<style>
body {
font-family: monospace;
text-align: left;
}
</style>
</head>
<body>
<h4>Iterations: <?php echo $iterations; ?> | Size: <?php echo $size; ?></h4>
<table>
<tr>
<th>set_theme_mod</th>
<th>update_option</th>
</tr>
<tr>
<td><?php echo $set_theme_mod; ?></td>
<td><?php echo $update_option; ?></td>
</tr>
<tr>
<th>get_theme_mod</th>
<th>get_option</th>
</tr>
<tr>
<td><?php echo $get_theme_mod; ?></td>
<td><?php echo $get_option; ?></td>
</tr>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment