Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 197611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T16:52:04+00:00 2026-05-11T16:52:04+00:00

I’m currently trying to optimize my website, which is run on the Google App

  • 0

I’m currently trying to optimize my website, which is run on the Google App Engine. It’s not an easy task, because I’m not using any powerful tool.

Does anyone have experience in optimizing Python code for this purpose?
Have you find a good Python profiler?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T16:52:04+00:00Added an answer on May 11, 2026 at 4:52 pm

    I have found Gprof2Dot extremely useful. The output of the profiling modules I’ve tried as pretty unintuitive to interpret.

    Gprof2Dot turns the cProfile output into a pretty looking graph, with the slowest chain(?) highlighted, and a bit of information on each function (function name, percentage of time spend on this function, and number of calls).

    An example graph (1429x1896px)

    I’ve not done much with the App Engine, but when profiling non-webapp scripts, I tend to profile the script that runs all the unittests, which may not be very accurate to real-world situations

    One (better?) method would be to have a script that does a fake WSGI request, then profile that.

    WSGI is really simple protocol, it’s basically a function that takes two arguments, one with request info and the second with a callback function (which is used for setting headers, among other things). Perhaps something like the following (which is possible-working pseudo code)…

    class IndexHandler(webapp.RequestHandler):
        """Your site"""
        def get(self):
            self.response.out.write("hi")
    
    if __name__ == '__main__':
        application = webapp.WSGIApplication([
            ('.*', IndexHandler),
        ], debug=True)
    
        # Start fake-request/profiling bit
        urls = [
            "/",
            "/blog/view/hello",
            "/admin/post/edit/hello",
            "/makeanerror404",
            "/makeanerror500"
        ]
    
        def fake_wsgi_callback(response, headers):
            """Prints heads to stdout"""
            print("\n".join(["%s: %s" % (n, v) for n, v in headers]))
            print("\n")
    
        for request_url in urls:
            html = application({
            'REQUEST_METHOD': 'GET',
            'PATH_INFO': request_url},
            fake_wsgi_callback
            )
            print html
    

    Actually, the App Engine documentation explains a better way of profiling your application:

    From http://code.google.com/appengine/kb/commontasks.html#profiling:

    To profile your application’s performance, first rename your application’s main() function to real_main(). Then, add a new main function to your application, named profile_main() such as the one below:

    def profile_main():
        # This is the main function for profiling 
        # We've renamed our original main() above to real_main()
        import cProfile, pstats
        prof = cProfile.Profile()
        prof = prof.runctx("real_main()", globals(), locals())
        print "<pre>"
        stats = pstats.Stats(prof)
        stats.sort_stats("time")  # Or cumulative
        stats.print_stats(80)  # 80 = how many to print
        # The rest is optional.
        # stats.print_callees()
        # stats.print_callers()
        print "</pre>"
    

    […]

    To enable the profiling with your application, set main = profile_main. To run your application as normal, simply set main = real_main.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I would like to run a str_replace or preg_replace which looks for certain words
We're building an app, our first using Rails 3, and we're having to build
I am using Paperclip to handle profile photo uploads in my app. They upload
I'm making a simple page using Google Maps API 3. My first. One marker
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.