João Pedro Francese avatar João Pedro Francese committed 2ba29f6

Easter egg in Profiler.

Comments (0)

Files changed (1)

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))
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.