Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8764281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T15:59:40+00:00 2026-06-13T15:59:40+00:00

I created a custom helper class module which I’m calling thusly: $bench = Mage::helper(‘benchmark’);

  • 0

I created a custom helper class module which I’m calling thusly:

$bench = Mage::helper('benchmark');
// ... do stuff ...
$bench->addBenchmark();
// ... more stuff ...
$bench->logResults();

This outputs the results of time benchmarks in an array.

The class is really simple, it basically just adds the current microtime() to an array then spits that array out when logResults() is called.

The problem is, I have a loop where I’m calling the code above, but instead of logging a “fresh” set of benchmark figures each loop, it’s compounding itself and adding to the existing benchmarks array!

I want it to create a new set of benchmarks each time Mage::helper('benchmark'); is called.

Any help is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T15:59:43+00:00Added an answer on June 13, 2026 at 3:59 pm

    With a helper that is not possible, unless you manually flush the content of the array upon calling the addBenchmark method.

    The problem lies in the following. Within Mage.php your requested helper is stored in the registry. Upon next call the exact same helper object will be retrieved from the registry, instead of a new one. It only creates an instance the first time the helper is called.

    /**
     * Retrieve helper object
     *
     * @param string $name the helper name
     * @return Mage_Core_Helper_Abstract
     */
    public static function helper($name)
    {
        if (strpos($name, '/') === false) {
            $name .= '/data';
        }
    
        $registryKey = '_helper/' . $name;
        if (!self::registry($registryKey)) {
            $helperClass = self::getConfig()->getHelperClassName($name);
            self::register($registryKey, new $helperClass);
        }
        return self::registry($registryKey);
    }
    

    You could opt for a model, since getModel() returns a new instance each time the factory method is called. Though in my opinion that is a case of bad programming and also hurts you on performance.

    I would opt for flushing the latest data upon making a new call to addBenchmark. If you want to store all data in the helper for later processing perhaps always return the latest key in the array? Though, thats a matter of choice and flavor, so I will leave that part up to you.

    Hopefully this helps you a bit!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I've created myself a custom form element which has a custom view helper.
I am creating a custom module in magento.I have created block class and phtml
I created custom adapter for listview which contain text and images, on click of
I have created custom cell in which there are n number of image views.
I created a custom UITableViewCell subclass which contains a button named testbtn . I
I have a custom connection factory class (which inherits from psycopg2.extensions.connection ) that I
I'm trying to create a custom helper like this: # app/controllers/my_controller.rb class MyController <
I understand how to use the IComparer interface with helper classes which provide custom
I would like to create my custom helper class, but I always get ErrorException
I have created a custom razor helper in my MVC4 Web application that I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.