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 866031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T09:44:09+00:00 2026-05-15T09:44:09+00:00

I want to know how to profile my code. I have gone through the

  • 0

I want to know how to profile my code.

I have gone through the docs, but as there were no examples given I could not get anything from it.

I have a large code and it is taking so much time, hence I want to profile and increase its speed.
I havent written my code in method, there are few in between but not completely.
I don’t have any main in my code. I want to know how to use profiling.
I’m looking for some example or sample code of about how to profile.

I tried psyco, i.e just addded two lines at the top of my code:

import psyco
psyco.full()

Is this right? It did not show any improvement.
Any other way of speeding up, please suggest.

  • 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-15T09:44:10+00:00Added an answer on May 15, 2026 at 9:44 am

    The standard answer to this question is to use cProfile.

    You’ll find though that without having your code separated out into methods that cProfile won’t give you particularly rich information.

    Instead, you might like to try what another poster here calls Monte Carlo Profiling. To quote from another answer:

    If you’re in a hurry and you can
    manually interrupt your program under
    the debugger
    while it’s being
    subjectively slow, there’s a simple
    way to find performance problems.

    Just halt it several times, and each
    time look at the call stack. If there
    is some code that is wasting some
    percentage of the time, 20% or 50% or
    whatever, that is the probability that
    you will catch it in the act on each
    sample.
    So that is roughly the
    percentage of samples on which you
    will see it. There is no educated
    guesswork required. If you do have a
    guess as to what the problem is, this
    will prove or disprove it.

    You may have multiple performance
    problems of different sizes. If you
    clean out any one of them, the
    remaining ones will take a larger
    percentage, and be easier to spot, on
    subsequent passes.

    Caveat: programmers tend to be
    skeptical of this technique unless
    they’ve used it themselves. They will
    say that profilers give you this
    information, but that is only true if
    they sample the entire call stack.
    Call graphs don’t give you the same
    information, because 1) they don’t
    summarize at the instruction level,
    and 2) they give confusing summaries
    in the presence of recursion. They
    will also say it only works on toy
    programs, when actually it works on
    any program, and it seems to work
    better on bigger programs, because
    they tend to have more problems to
    find [emphasis added].

    It’s not orthodox, but I’ve used it very successfully in a project where profiling using cProfile was not giving me useful output.

    The best thing about it is that this is dead easy to do in Python. Simply run your Python script in the interpreter, press [Control-C], note the traceback and repeat a number of times.

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

Sidebar

Related Questions

We have a thick client app using jQuery heavily and want to profile the
I want to have multiple path folder structure that contain same name views: /profile.aspx
I know there are a few questions about similar topics but they mostly amount
Want to know what the stackoverflow community feels about the various free and non-free
want to know why String behaves like value type while using ==. String s1
I want to know what a virtual base class is and what it means.
I want to know what are the options to do some scripting jobs in
I want to know what exactly is the sequence of calls that occurs when
I want to know which tool can be used to measure the cyclomatic complexity
I want to know how to use variables for objects and function names in

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.