Created
April 23, 2015 15:05
-
-
Save MKorostoff/4aa2da788dfbd23fca76 to your computer and use it in GitHub Desktop.
Load 5000 virtual blocks with 8 random tags each
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
<?php | |
for ($i=1; $i <= 10; $i++) { | |
$start = microtime(true); | |
for ($ii=0; $ii < 5000; $ii++) { | |
//Pick 8 random tids to search for | |
$tids = array(); | |
for ($iii=0; $iii < 8; $iii++) { | |
$tids[] = rand(500, 1000000); | |
} | |
//Stuff the randomly selected tids into an array compatible with db_query | |
$args = array( | |
":tids" => $tids | |
); | |
//Get a ranked list of the 5 nodes which have the most matches | |
$query = db_query("SELECT nid,count(tid) | |
FROM taxonomy_index | |
WHERE tid | |
IN (:tids) | |
GROUP BY nid | |
ORDER BY count(tid) DESC | |
LIMIT 5", $args); | |
$result = $query->fetchAll(); | |
} | |
print "Run $i: " . (microtime(true) - $start) . ' seconds' . "\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment