Skip to content

Instantly share code, notes, and snippets.

@PrafullaKumarSahu
Forked from anonymous/test.php
Created October 19, 2015 13:12
Show Gist options
  • Save PrafullaKumarSahu/e89b095dd522768d6637 to your computer and use it in GitHub Desktop.
Save PrafullaKumarSahu/e89b095dd522768d6637 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