Jump to content

[SOLVED] Which Loads Faster?


Leeder

Recommended Posts

if took 0.030161857605

Switch took 0.036612033844

 

in a loop of 1000

 

time to took to find someone who cares ..... (still running) ;D

 

 

Well I'm sure people didn't worry about the wheel before it was invented.

 

You know how dumb thats sounded ?

As a side note

 

functions work better when used correctly

 

ie

<?php

switch ($user['vipage']) {
case "0":
  break;
case "1":
  break;
case "2":
  break;
case "3":
  break;
default:
  echo "";
  break;
}

?>

 

runs quicker than

 

<?php

if ($user['vipage'] == 0)
{
	echo "";
}elseif ($user['vipage'] == 1)
{
	echo "";
}elseif ($user['vipage'] == 2)
{
	echo "";
}elseif ($user['vipage'] == 3)
{
	echo "";
}
?>

 

 

and yep again dumb

<?php

if ($user['vipage'] == 0)
{
	echo "";
}elseif ($user['vipage'] == 1)
{
	echo "";
}elseif ($user['vipage'] == 2)
{
	echo "";
}elseif ($user['vipage'] == 3)
{
	echo "";
}
?>

 

That's so ugly lol

 

<?php

if ($user['vipage'] == 0) {
echo "";
}

elseif ($user['vipage'] == 1) {
echo "";
}

elseif ($user['vipage'] == 2) {
echo "";
}

elseif ($user['vipage'] == 3) {
echo "";
}

?>

 

Much better ^-^

Why worry about the speed?

The difference in so minute no one would know!

 

Well when you are making a MASSIVE program/application a half second here and there add up to a lot of time. But for a small application it doesn't matter as much, BUT you should always be aware of speed.

Why worry about the speed?

The difference in so minute no one would know!

 

Well when you are making a MASSIVE program/application a half second here and there add up to a lot of time. But for a small application it doesn't matter as much, BUT you should always be aware of speed.

 

True, but I think he wont be making big scripts for a while...

Why worry about the speed?

The difference in so minute no one would know!

 

Well when you are making a MASSIVE program/application a half second here and there add up to a lot of time. But for a small application it doesn't matter as much, BUT you should always be aware of speed.

 

True, but I think he wont be making big scripts for a while...

 

Why, because of my coding style?

On top of that speed question doing this:

 

echo "{$var['1']}";

 

takes more time to process than this:

 

echo "Variable 1: " . $var['1']; 

//or even
echo "Variable 1: ", $var['1']; 

 

If you are concerned about speed. Either or It all depends on your coding style and what you are trying to do. If you have 10 variations switch is better where as if there is only 2, probably if/elseif/else. Either way it is like 1 millionth of a second difference which does not make much of a difference at all.

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.