Development

#4287 (Useless sfTimer::startTimer() call in sfTimerManager::getTimer())

You must first sign up to be able to contribute.

Ticket #4287 (closed defect: fixed)

Opened 4 months ago

Last modified 1 month ago

Useless sfTimer::startTimer() call in sfTimerManager::getTimer()

Reported by: shouze Assigned to: fabien
Priority: minor Milestone: 1.1.5
Component: other Version: 1.1.5
Keywords: sfTimerManager sfTimer Cc:
Qualification: Unreviewed

Description

Because sfTime already calls the startTimer() method at construction, the following code is wrong :

<?php
  public static function getTimer($name)
  {
    if (!isset(self::$timers[$name]))
    {
      self::$timers[$name] = new sfTimer($name);
    }

    self::$timers[$name]->startTimer();

    return self::$timers[$name];
  }

?>

So the code should be :

<?php
  public static function getTimer($name)
  {
    if (!isset(self::$timers[$name]))
    {
      self::$timers[$name] = new sfTimer($name);
    }

    return self::$timers[$name];
  }
?>

Change History

08/29/08 19:34:11 changed by FabianLange

uhm.. it would break existing functionality. as currently getTime() will reset the starttime. But I am not sure if this is intentional. Perhaps its not even unnecessary but even a bug.

11/09/08 09:24:40 changed by fabien

  • status changed from new to closed.
  • resolution set to fixed.

(In [12807]) [1.1, 1.2] removed unneeded code (closes #4287)

11/09/08 11:47:03 changed by fabien

  • milestone set to 1.1.5.

11/25/08 09:48:41 changed by thibaultd

  • status changed from closed to reopened.
  • version changed from 1.2.0 DEV to 1.1.5.
  • resolution deleted.
self::$timers[$name]->startTimer();

is necessary when a timer is called many times. In symfony 1.1.5, when sfTimer::addTime() method is called, it adds the time since the first call of the timer, instead of the last one. It results on huge, unreal times.

I suggest to go back to :

<?php
  public static function getTimer($name)
  {
    if (!isset(self::$timers[$name]))
    {
      self::$timers[$name] = new sfTimer($name);
    }

    self::$timers[$name]->startTimer();

    return self::$timers[$name];
  }

?>

11/25/08 15:58:06 changed by fabien

  • status changed from reopened to closed.
  • resolution set to fixed.

(In [13339]) [1.1, 1.2] reverted r12807 (closes #4287)