Posts Tagged ‘seconds’

ini_alter vs ini_set in php

Tuesday, July 15th, 2008

Finally lets look at modifying the environment. I actually cheated here and just set the max execution time to 60 seconds a million times. I think the result is still valid though

ini_alter vs ini_set
ini_alter: 103.332370043 seconds
ini_set: 86.2883789539 seconds
Time saved: 17.0439910889 seconds; 19.7523598143%

As might be expected these functions are expensive when it comes to execution time. That 17 microsecond saving is massive as well making ini_set the superior choice.

implode vs join in php

Tuesday, July 15th, 2008

This one really surprised me. I expected these functions to be faster. Both these functions allow you to convert an array into a string. implode is the opposite of explode and join allows you to join the items in an array with a ‘glue’ string. In this case the array had 100 items.

implode vs join
implode: 47.2712550163 seconds
join: 50.1287050247 seconds
Time saved: 2.85745000839 seconds; 5.70022705949%

5% doesn’t seem like all that much but 2 microseconds shouldn’t be ignored.

SEO:Free Search Engine Submission Sites/Tools

Monday, June 30th, 2008

*  Submit Corner

You’ll like this submission tool because it allows you to choose the search engines you want to submit to. This wizard usually takes under 30 seconds and you’ll have your site submitted to the top engines instantly. It also has other cool tools you can use to optimize and improve your web site. It’s a great resource site!
http://www.submitcorner.com/Tools/Submit/

* SubmitPlus

Good tool because you have to fill only two fields (Email and URL) and their service effectively submits your web site to the top 10 search engines in less than 1 minute! Its other cool features include real time status reporting, live confirmation link and an email report.
http://www.submitplus.com/top10.htm

MYSQL:Calculate TIMEDIFF with mysql version < 4.1

Monday, June 30th, 2008

// TIMEDIFF between two dates and the result is in seconds
SELECT ((TO_DAYS(DATE_FORMAT(’1997-10-04 22:23:00′, ‘%Y-%m-%d’)) * 86400) +
TIME_TO_SEC(DATE_FORMAT(’1997-10-04 22:24:00′, ‘%T’)))
- ((TO_DAYS(DATE_FORMAT(’1997-10-04 22:24:00′, ‘%Y-%m-%d’)) * 86400) +
TIME_TO_SEC(DATE_FORMAT(’1997-10-04 22:22:00′, ‘%T’)))

Fastest type of loop

Saturday, June 28th, 2008

In PHP, there are a number of loops available for you to use. There are while loops, do-while loops, and for loops. To see which one of these were fastest, I used each of them to perform 100,000,000 iterations. These are the loops which I used:

while(++$a<100000000){}

for(;++$a<100000000;){}

do{}while(++$a<100000000)

Here are my results:

while(++$a<100000000){}: 15.519 seconds
for(;++$a<100000000;){}: 17.577 seconds
do{}while(++$a<100000000): 13.744 seconds

As you can see, my results show that a do-while loop is 21.81% faster, compared to a for loop.

Use time() rather than date(’U')

Saturday, June 28th, 2008

When you want to get the current Unix timestamp, it is faster to use time() rather than date(’U'). To test this, I used the time() function 100,000 times, followed by date(’U') 100,000 times. My results are as follows:

date(’U'): 19.162 seconds
time(): 0.057 seconds
Time saved: 19.105 seconds; 99.7%

Pre-increment is faster than post-increment

Saturday, June 28th, 2008

Try to pre-increment, rather than post-increment, where possible. It is faster because post-increment creates a temporary variable while in the process of incrementing. So, this:

++$var;

…is faster than this:

$var++;

This rule also applies to decrementation as well. To test this assertion, I created two for loops. The first for loop used the post-increment option, while the second for loop used pre-increment instead. The total number of iterations was 10,000,000. Here are the results:

Post-increment: 2.148 seconds
Pre-increment: 1.692 seconds
Time saved: 0.456 seconds; 21.23%

split() or explode()

Saturday, June 28th, 2008

The split() function supports regular expressions, while explode() does not. It is often faster to use explode() when you do not need to use regular expressions.I done yet another test. I used split() to split a string without regular expression requirements, and then used explode() to split the same string. I repeated this 1,000,000 times. My results are:

split(): 5.453 seconds
explode(): 3.556 seconds
Time saved: 1.897 seconds; 34.79%

Titles Matter

Thursday, June 26th, 2008

You only have seconds to grab the attention of scanners browsing your blog. Use keywords and catchy titles to draw readers in. Blog post titles can be bolded for emphasis and white space should be used to buffer the content.

Crack BIOS Password !!!

Wednesday, June 18th, 2008

Forgot BIOS Password ?

Do the following :

1. Open the CPU
2. Now, observe the motherboard.
3. You notice a coin like silver Battery(3V).

NOTE

This battery is 24 x 7 power supply for the BIOS, which is used to run the system clock will the main power is off. It also initiates the booting process when power is switched on.

4. Remove the battery from the motherboard.
(It is safe to remove the Battery)

5. Wait 30 seconds and place the battery back on the motherboard.

6. Now, when you start your system you won’t be prompted for the BIOS password.

Enjoy !!!

CAUTION

1. Perform on your own risk !

2. You have to set the time of your computer when you start again.