Done with the fixes in 1.9.9
I've done some tests with your database and wrote up the following shell to test things out. You can replace the call in there with whatever you want. Your debug output also led me to some older code internally that could be better.
Then after I realized that SQL was caching my results, so the first number was the most accurate, you can ignore the mean and all that at the bottom. First number is the most useful currenly.
I am going to work in an option to add SQL: SELECT SQL_NO_CACHE so that this can be tested pretty easily. Then Mean and stuff will be MEANingful (get it? sorry... could not resist it)
Regardless... the two that you mentioned:
For cpm_showAlbumsUpdatedOverLastDays(10, array('alttag' => '%a %w', 'subtitle' => '%a, %f', 'imagelink' => 'album')):
(You can see the difference after the first two with caching)
Not bridged: 0.272 0.219 0.010 0.003 0.004 0.004 0.003
Default bridged: 0.283 0.247 0.004 0.003 0.003 0.003
Default bridged with rendering: 0.235 0.006 0.470 0.201 0.051 0.029
I can live with this...
Now this one is a bit wierd...
For cpm_viewRandomMedia(1,5, array('alttag' => '%a, %f')):
Default bridged with rendering: 0.580 0.543 0.453 0.483 0.458 0.482
Not bridged: 0.828 0.678 0.667 0.725 0.671 0.667
Holy cow... that is the simplest thing I do.
If we replace the %f with the new way (saves an iteration) it does not seem to help.
cpm_viewRandomMedia(1,5, array('alttag' => '{{aTitle}}, {{pFilename}}')):
0.795 0.722 0.653 0.688 0.698 0.652
0.774 0.678 0.665 0.701 0.682 0.677
If I remove the order by rand(), the SQL response from the command line, drops from 0.64 to 0.0
Ordering by time lands us at 0.16
So I guess having SQL do the rand order by is not terribly good at large datasets.
Narrowing the randomization down to just cat=27 (In which you have about 2000 photos) gives us:
0.117 0.157 0.098 0.086 0.070 0.107
So, yes - it is probably that whole ORDER BY rand() thing.
I will see what I can do, but you could always limit it to a category or something for now...
I am opting to not include benchmarking, since the microtime requires certain system functions to work - some of which may not be on windows machines. So I am keeping it out of the core.
Here is my, somewhat flawed, benchmarking shell - I will be including it in the next and future downloads also...
<?php
error_reporting(E_ALL);
ini_set('display_errors',1); // 0 is off, 1 is on
include "./cpmfetch.php";
$objCpm = new cpm();
// You can comment this out to test rendering time also
$objCpm->cpm_setReturnType("resultset");
$objCpm->cpm_debugMode(true);
?>
<?php
$results = array();
// Leave this call in. It forces cpmFetch to create a database connection. Otherwise it will throw off the first result.
$objCpm->dbConnect();
for ($x = 0; $x < 101; $x++) {
$starttime = explode(' ', microtime());
$starttime = $starttime[1] + $starttime[0];
//$objCpm->cpm_viewRandomMedia(1,5, array('alttag' => '%a, %f'));
$objCpm->cpm_showAlbumsUpdatedOverLastDays(10, array('alttag' => '%a %w', 'subtitle' => '%a, %f', 'imagelink' => 'album'));
//$objCpm->cpm_getAlbumListFrom("",1,3);
$mtime = explode(' ', microtime());
$totaltime = $mtime[0] + $mtime[1] - $starttime;
array_push($results,$totaltime);
}
$x = 0;
foreach($results as $entry) {
//printf('Iteration ' . $x . ': Page loaded in %.3f seconds.<br>', $entry);
printf(' %.3f ', $entry);
$x++;
}
sort($results);
print "<p>Max is: {$results[100]}<br />";
print "Min is: {$results[0]}<br />";
print "Mean is: {$results[50]}<br />";
print "Average is: " . array_sum($results)/sizeof($results) . "</p>";
$objCpm->cpm_close(); ?>
- vuud