Create breakpoints to time code at

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
# By Ed and Rudy Menendez
import time
class Timer(object):
    def __init__(self):
        self.bot = self.last_time = time.time()
        print u'Starting timer at %s' % self.last_time

    def tick(self, msg='Timer'):
        x = time.time()
        print '%s: Since inception %.3f, since last call %.3f' % (msg, x-self.bot, x - self.last_time)
        self.last_time = x

More like this

  1. Request time logging middleware by mpasternacki 4 years, 4 months ago
  2. Optimized humanize naturalday filter by c2j 4 years, 7 months ago
  3. Timing Django Requests by metajack 5 years, 10 months ago
  4. FormWizard inside view with proper context handling and site templating support, without having to use urls.py by sleepycal 4 years, 4 months ago
  5. Color SQL logging middleware by moe 6 years, 2 months ago

Comments

(Forgotten your password?)