473,395 Members | 1,937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

What are good ways for keeping your script faster then 47.01 seconds?

Ajm113
161 100+
Ok, as some of you may know I am making a search engine and right now it takes atleast 47 or 40 seconds to load up 5 or more results here is what it is doing;

1.Load logo, textbox, what the user is searching for.

2.Get user info and connect to mysql

3.Select and search the mysql tables.

4.Do a while statment and pull up the websites and look at the description meta tag and pull it up to display.

5.If they don't just use the description in the database.

6.Load the image and text on each result.

7.Echo the number of results and "top" button when done.

What are some tips and tricks on keeping load time faster? My results page praticly has no special effects or very advanced CSS Designs in it.
Jun 14 '07 #1
7 1153
Purple
404 Expert 256MB
Hi Ajm113,

The first thing you need to do is work out where the bulk of the 47 second is being taken. I suggest you write timed log event through your code and apply pareto's law

Purple
Jun 14 '07 #2
Ajm113
161 100+
I think its the meta checking area where it checks if the site has a description meta tag that is making it slower. Isn't there shortcuts to this?

[PHP]while($row=mysql_fetch_array($query)) { // Starts spitting out the data

$url=$row["url"];
$title=$row["title"];

$fp = fopen( $url, 'r' );

$content = "";


while( !feof( $fp ) ) {

$buffer = trim( fgets( $fp, 4096 ) );
$content .= $buffer;

}

$metatagarray = get_meta_tags( $url );
$description = $metatagarray[ "description" ];
$description = substr($description,0,240);

if($description == '')
{
$description=$row["description"];
}
//echo out results
}
[/PHP]
Jun 14 '07 #3
Purple
404 Expert 256MB
Hi Ajm113,

I thnik I agree with you - might be worth writing a logging function to confirm your suspicions....

But back to the question - cant you write a process which caches the meta data and saves it in your database so you dont need to pull it back for every query ?

My thoughts - everyone else welcome to join in :)

Purple
Jun 14 '07 #4
Ajm113
161 100+
I thought about that, but then if someone was supposed to change the look of their site or had a metatag that updated everyday then thats when I made that. So if it finds the description tag it would desplay it and if it didn't. To save some time for the user. The script would pull the description from the database.
Jun 14 '07 #5
Purple
404 Expert 256MB
Hi,

That is what I expect would be most efficient, just have you background process running on an appropriate interval updating the tags etc on the database - obviously as your database grows it will take longer to update the tag detail..

Let us know how you go on.

Good luck and regards

Purple
Jun 15 '07 #6
pbmods
5,821 Expert 4TB
Is your MySQL database indexed properly? Check your slow_query_log.

Try EXPLAINing your queries and make sure you're not doing full scans where you don't have to.
Jun 15 '07 #7
Motoma
3,237 Expert 2GB
Hi Ajm113,

I thnik I agree with you - might be worth writing a logging function to confirm your suspicions....

But back to the question - cant you write a process which caches the meta data and saves it in your database so you dont need to pull it back for every query ?

My thoughts - everyone else welcome to join in :)

Purple
Yes, the process of collecting meta tags is likely your issue, as you have to synchronously perform a read of other URLs.
Your best bet would be to cache the meta tags, and update them on a regular basis.
Jun 15 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: krystoffff | last post by:
Hi all ! I've got a very weird problem ! I was trying to make my PHP script to send emails to every subscribed member to go faster (each email takes 1 or 2 seconds to be sent !) so I tried to...
7
by: Dennis Roberts | last post by:
I have a script to parse a dns querylog and generate some statistics. For a 750MB file a perl script using the same methods (splits) can parse the file in 3 minutes. My python script takes 25...
0
by: SPD | last post by:
I've been researching this issue with little luck. Here's the situation: We have a few users on slow dialup connections who are posting data from forms. Frequently, they get script timeout...
121
by: typingcat | last post by:
First of all, I'm an Asian and I need to input Japanese, Korean and so on. I've tried many PHP IDEs today, but almost non of them supported Unicode (UTF-8) file. I've found that the only Unicode...
13
by: Jason Huang | last post by:
Hi, Would someone explain the following coding more detail for me? What's the ( ) for? CurrentText = (TextBox)e.Item.Cells.Controls; Thanks. Jason
34
by: emrahayanoglu | last post by:
Hello Everyone, Now, I'm working on a new web framework. I tried many test on the other programming languages. Then i decided to use python on my web framework project. Now i want to listen...
1
by: markscala | last post by:
I found the following ways to generate permutations on the ASPN: Python Cookbook page. SLOW (two defs): def xcombinations(items,n): if n == 0: yield else: for i in xrange(len(items)): for...
7
by: Wisgary | last post by:
I'm doing some benchmarking tests to compare Microsoft's CLR against Mono's CLR. I could use some suggestions for how to objectively compare the code. To my surprise the few tests I've run so far...
10
by: timor.super | last post by:
Hi all, Imagine I've an array of int : int anArray = new int; I want to extract all the integer that are superior to 500 I can do :
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.