Commits

João Pedro Francese committed 2ba29f6

Easter egg in Profiler.

  • Participants
  • Parent commits a5d218f

Comments (0)

Files changed (1)

File inoa/utils/profiling.py

 """
 
 profiler_enabled = settings.DEBUG or getattr(settings, 'ENABLE_PROFILER_IN_PRODUCTION', False)
+bolt_easter_egg = getattr(settings, 'PROFILER_BOLT_EASTER_EGG', False)
 logger = logging.getLogger('profiling')
 
 def method_profiler(method):
         q2 = len(connection.queries) #@UndefinedVariable
         self.count += 1
         name = name or self.count
-        logger.debug("Partial %s in %.04f seconds with %s queries." % (name, t2 - self.t1, q2 - self.q1))
+        if bolt_easter_egg:
+            logger.debug("Bolt would have run %.01f meters during partial %s, with %s queries." % ((t2 - self.t1)*10.4389, name, q2 - self.q1))
+        else:
+            logger.debug("Partial %s in %.04f seconds with %s queries." % (name, t2 - self.t1, q2 - self.q1))
         self.t1, self.q1 = t2, q2
         self.__class__.latest_instance = self
 
             return
         t2 = time.time()
         q2 = len(connection.queries) #@UndefinedVariable
-        logger.debug("Executed %s in %.04f seconds with %s queries." % (self.name, t2 - self.t0, q2 - self.q0))
+        if bolt_easter_egg:
+            logger.debug("Bolt would have run %.01f meters during execution of %s, with %s queries." % ((t2 - self.t0)*10.4389, self.name, q2 - self.q0))
+        else:
+            logger.debug("Executed %s in %.04f seconds with %s queries." % (self.name, t2 - self.t0, q2 - self.q0))