Random Image Block Makes Page Load Slow

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Random Image Block Makes Page Load Slow
mjhufford
CZ Active Member
 Codezwiz Site Donator
mjhufford has been a member for over 20 year's 20 Year Member
usa.gif arkansas.gif
Occupation: IT Industry
Age: 47
Gender: Male
Fav. Sports Team: Da Bears.
Website:
Status: Offline
Joined: Jul 01, 2004
0.04 posts per day
Posts: 288
Points: 15,094
  MSN Messenger 
Howdy all,

I'm using the Random Image block on my site (Telli's block) and it makes the page load really slow. It takes 4 to 6 seconds on average to load. If I disable the block, it loads in less than a second. Is this just the nature of that block and the functions it has to run before the page can be displayed or posted?

TIA,

MJ




_________________
"The pursuit of easy things makes men weak."
-David O. McKay
Back to top Reply with quote
#2   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,475
   
Try adding a test one with little images see if it is really slow. The rand function is a little slow but where talking 10th's of seconds.




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   
mjhufford
CZ Active Member
 Codezwiz Site Donator
mjhufford has been a member for over 20 year's 20 Year Member
usa.gif arkansas.gif
Occupation: IT Industry
Age: 47
Gender: Male
Fav. Sports Team: Da Bears.
Website:
Status: Offline
Joined: Jul 01, 2004
0.04 posts per day
Posts: 288
Points: 15,094
  MSN Messenger 
I'm using about 100 different images...does that make a difference? Non of the pics are over 15 kb or so.




_________________
"The pursuit of easy things makes men weak."
-David O. McKay
Back to top Reply with quote
#4   
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,475
   
You would be better off making a database to hold them.


CREATE TABLE `nuke_random_images` (
  `id` int(11) NOT NULL auto_increment,
  `picname` varchar(255) NOT NULL default '',
  `picurl` varchar(255) NOT NULL default '',
  `pichits` bigint(11) NOT NULL default '0',
  PRIMARY KEY  (`id`),
) TYPE=MyISAM;


Then make a block to display it.


<?php
if (strpos('block-Random_Image.php', $_SERVER['SCRIPT_NAME'])) {
    Header("Location: ../../");
    exit;
}

global $prefix, $db;
$show = '';
$result = $db->sql_query("SELECT picname, picurl, pichits FROM {$prefix}_random_images ORDER BY RAND() DESC LIMIT 1");
while(list($picname, $picurl, $pichits) = $db->sql_fetchrow($result)) {
    $show .= '<img src="'.$picurl.'" title="'.$picname.'"><br />'.$picname.'<br />Hits: '.$pichits.'<br />\n';
}
$content .= $show;
?>




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum