Skip to content

Instantly share code, notes, and snippets.

@rajeshtaneja
Last active August 29, 2015 14:23
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 rajeshtaneja/31ed8a54f48d28f5b958 to your computer and use it in GitHub Desktop.
Save rajeshtaneja/31ed8a54f48d28f5b958 to your computer and use it in GitHub Desktop.
Test script to check performance improvement with UNION ALL
<?php
/*
* Test script to loop though get_user_access_sitewide()
* for each user to get performance results with UNION ALL
*/
define('CLI_SCRIPT', true);
include_once("config.php");
// Max users to get access info of.
$MAX_USERS=64000;
$starttime = microtime(true);
// Loop though the users and get capabilities.
for($i=1; $i < $MAX_USERS; $i++) {
if ($DB->record_exists('user', array('id'=>$i))) {
get_user_access_sitewide($i);
// Show progress.
echo ".";
if (($i % 70) == 0) {
echo " " . $i . PHP_EOL;
}
}
}
$timetaken = microtime(true) - $starttime;
echo $timetaken . PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment