Trying to use the timer functions to measure performance issues, I found that timers called multiple times (e.g., timer_start('saveIDMapping'); timer_stop('saveIDMapping'); timer_start('saveIDMapping'); timer_stop('saveIDMapping);) reported ridulously high values. The problem is that timer_read() returns the full accumulated time across all calls, and timer_stop() adds the timer_read() value to the already-accumulated value - thus, after the first read $timers[$name]['time'] gets double-counted each time (can you say "exponential"? good...).

Patch forthcoming...

CommentFileSizeAuthor
#1 timer_stop.patch972 bytesmikeryan
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

mikeryan’s picture

Status: Active » Needs review
FileSize
972 bytes

Note related issue #84008: timer_read() returns NULL (no value) after timer_stop() - this fix should be added to the D6 patch there.

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

fix looks proper to me.

webchick’s picture

Status: Reviewed & tested by the community » Needs review
Issue tags: +Needs tests

Is there a way to add a test for this, by chance?

moshe weitzman’s picture

Status: Needs review » Reviewed & tested by the community

We could add a test which calls timers 3 times and sleeps for a couple seconds between each but thats gonna slow down the whole suite and i don't really see that much benefit. If you do timings for something other than sleep() then you have little clue about how accurate your timer is.

Considering that nothing breaks if timers break, and considering that this API has hardly changed in 8 years, I think we can proceed with this bug fix without a test. Please.

Dries’s picture

Status: Reviewed & tested by the community » Fixed

I'm comfortable with this patch without test so I committed it to CVS HEAD.

Status: Fixed » Closed (fixed)
Issue tags: -Needs tests

Automatically closed -- issue fixed for 2 weeks with no activity.