Jump to content

Cause of weak performance


Recommended Posts

I measured response time of website. The original response time is about 20-25 s.

After that, I uninstalled category block, response time reduce to 4-5 s. Surprisingly,  :o

I opened category block's code, I found that there are too many call for template (to recursive to make tree). That's bad technique.

 

I think weak performance caused by programming technique not by smarty technology.

Any one find more cause, pls public for our community. It's very good if these causes are removed.

Link to comment
Share on other sites

There are some ways to speed up website:

1. Don't use smart technique. Following function is to get HTML code for category tree without smarty. Website's speed is doubled

 

    function getHTMLCategTree($catSelected=0, $maxDepth = 3, $currentDepth = 0, $idLang = NULL)

    {

        global $link;

 

        //get idLang

        $idLang = is_null($idLang) ? _USER_ID_LANG_ : intval($idLang);

 

        //recursivity for subcategories

        $childrenNodes = "";

        $subcats = $this->getSubCategories($idLang, true);

        if (sizeof($subcats) AND ($maxDepth == 0 OR $currentDepth < $maxDepth)) {

            foreach ($subcats as $subcat)

            {

                if (!$subcat['id_category'])

                    break ;

                $categ = new Category($subcat['id_category'] ,$idLang);

                $HTMLcatItem = "<li>";

                if ($catSelected == $categ->id)

                    $HTMLcatItem = $HTMLcatItem . '<a href="'.$link->getCategoryLink($categ->id, $categ->link_rewrite).'" class="selected" title="'.$categ->description.'">'.$categ->name.'</a>';

                else

                    $HTMLcatItem = $HTMLcatItem . '<a href="'.$link->getCategoryLink($categ->id, $categ->link_rewrite).'" title="'.$categ->description.'">'.$categ->name.'</a>';

                $HTMLcatItem = $HTMLcatItem .$categ->getHTMLCategTree($catSelected, $maxDepth, $currentDepth + 1, $idLang);

                $HTMLcatItem = $HTMLcatItem . "</li>";

                $childrenNodes = $childrenNodes . $HTMLcatItem;

            }

            $childrenNodes = "<ul>" . $childrenNodes . "</ul>";

        }

        return $childrenNodes;

    }   

 

2. If you want to use smarty, let set cache for smarty object. This improves speed surprisingly.

 

Best regard,

;D

 

Link to comment
Share on other sites

  • 7 months later...
  • 9 months later...
  • 4 weeks later...
×
×
  • Create New...