@@ -0,0 +1,1443 @@
+import hotshot%0Aimport os%0Aimport time%0Aimport settings%0Aimport tempfile%0A%0Atry:%0A    PROFILE_LOG_BASE = settings.PROFILE_LOG_BASE%0Aexcept:%0A    PROFILE_LOG_BASE = tempfile.gettempdir()%0A%0A%0Adef profile(log_file):%0A    %22%22%22Profile some callable.%0A%0A    This decorator uses the hotshot profiler to profile some callable (like%0A    a view function or method) and dumps the profile data somewhere sensible%0A    for later processing and examination.%0A%0A    It takes one argument, the profile log name. If it's a relative path, it%0A    places it under the PROFILE_LOG_BASE. It also inserts a time stamp into the %0A    file name, such that 'my_view.prof' become 'my_view-20100211T170321.prof', %0A    where the time stamp is in UTC. This makes it easy to run and compare %0A    multiple trials.     %0A    %22%22%22%0A%0A    if not os.path.isabs(log_file):%0A        log_file = os.path.join(PROFILE_LOG_BASE, log_file)%0A%0A    def _outer(f):%0A        def _inner(*args, **kwargs):%0A            # Add a timestamp to the profile output when the callable%0A            # is actually called.%0A            (base, ext) = os.path.splitext(log_file)%0A            base = base + %22-%22 + time.strftime(%22%25Y%25m%25dT%25H%25M%25S%22, time.gmtime())%0A            final_log_file = base + ext%0A%0A            prof = hotshot.Profile(final_log_file)%0A            try:%0A                ret = prof.runcall(f, *args, **kwargs)%0A            finally:%0A                prof.close()%0A            return ret%0A%0A        return _inner%0A    return _outer%0A

Create profile_views.py