0

I wonder if it is better to write:

    $lesser2000 = Mage::helper('wr_epo')->getFensterbankTill2000mm($quote);
    $higher2000 = Mage::helper('wr_epo')->getFensterbankHigherThen2000mm($quote);
    $lesser3000 = Mage::helper('wr_epo')->getFensterbankTill3000mm($quote);
    $higher3000 = Mage::helper('wr_epo')->getFensterbankHigherThen3000mm($quote);
    $sumFensterbank = Mage::helper('wr_epo')->getFensterbankTotal($quote);
    $totalCartWeight = Mage::helper('wr_epo')->getFensterbankTotalWeight($quote);

or:

    $wrEpo = Mage::helper('wr_epo')

    $lesser2000 = $wrEpo->getFensterbankTill2000mm($quote);
    $higher2000 = $wrEpo->getFensterbankHigherThen2000mm($quote);
    $lesser3000 = $wrEpo->getFensterbankTill3000mm($quote);
    $higher3000 = $wrEpo->getFensterbankHigherThen3000mm($quote);
    $sumFensterbank = $wrEpo->getFensterbankTotal($quote);
    $totalCartWeight = $wrEpo->getFensterbankTotalWeight($quote);

Which is better for performance? Or does it make no difference?

7
  • Do you really want to benchmark this? ;) I really care about performance, but this is negligible.
    – sv3n
    Oct 22, 2018 at 17:19
  • @sv3n, you are thinking in a small scale. If there are thousands of users, then the impact is much higher.
    – Black
    Oct 23, 2018 at 7:13
  • I doubt it, but you seem to have found your answer.
    – sv3n
    Oct 23, 2018 at 9:03
  • Imagine a site like amazon, if this costs 0.0001 second more, then it already takes 10 seconds if there are 100.000 requests.
    – Black
    Oct 23, 2018 at 9:48
  • This would be the case if one request would call the helper 100.000 times ...
    – sv3n
    Oct 23, 2018 at 11:25

1 Answer 1

1

Not benchmarked, but I think is no big difference in performace. After first load Mage::helper() just returns data from registry.

public static function helper($name)
{
    $registryKey = '_helper/' . $name;
    if (!isset(self::$_registry[$registryKey])) {
        $helperClass = self::getConfig()->getHelperClassName($name);
        self::register($registryKey, new $helperClass);
    }
    return self::registry($registryKey);
}

If I have to call Mage::helper() multiple times I use a variable for my helper.


When you use Mage::helper('wr_epo') it just uses !isset() ... benchmark here:

With $helper = Mage::helper('wr_epo') it takes some memory for the variable ...

Which is better for performance? Or does it make no difference?

IMHO it makes no difference, but in doubt i'd use first (w/o variable) ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.