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

  • Home
  • SEARCH
  • 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 161791
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T11:16:33+00:00 2026-05-11T11:16:33+00:00

I am using cProfile to profile the leading function of my entire app. It’s

  • 0

I am using cProfile to profile the leading function of my entire app. It’s working great except for some 3rd party libraries that are being profiled, and shown in the output as well. This is not always desirable when reading the output.

My question is, how can i limit this? The documentation on python profilers mentions:

p.sort_stats('time', 'cum').print_stats(.5, 'init') 

This line sorts statistics with a primary key of time, and a secondary key of cumulative time, and then prints out some of the statistics. To be specific, the list is first culled down to 50% (re: .5) of its original size, then only lines containing init are maintained, and that sub-sub-list is printed.

It mentions that lines containing ‘init’ will only be displayed. This works great, but i want to limit it in such a way so that i can say, limit lines containing ‘init’ and/or ‘get’. By trial and error i found that you can add another argument, a string, and it will be filtered further to display only lines containing string1 and string2. Using my previous example, this would look like:

p.sort_stats('time', 'cum').print_stats(.5, 'init', 'get') 

Anyone know how you could limit the lines so that only lines containing ‘init’ and/or ‘get’ would be displayed?

  • 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. 2026-05-11T11:16:34+00:00Added an answer on May 11, 2026 at 11:16 am

    Per the docs you linked, the strings are regular expressions:

    Each restriction is either an integer …, or a regular expression (to pattern match the standard name that is printed; as of Python 1.5b1, this uses the Perl-style regular expression syntax defined by the re module)

    Accordingly:

    p.sort_stats('time', 'cum').print_stats(.5, 'init|get') 

    should work.

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

Sidebar

Related Questions

I've been using cProfile to profile my code, and it's been working great. I
I'd like to profile a method of a function in Python, using cProfile. I
I'm currently using cProfile and pstats to profile some Python code. Is there a
I'm using cProfile to profile my Python program. Based upon this talk I was
I'm profiling in Python using cProfile . I found a function that takes a
I'm using python -m cProfile -s calls myscript.py python -m cProfile -s percall myscript.py
I have create three developer profile (like A,B,C) with wildcard APP ID. First, I
I am using python, and suppose i had some code as below example.py import
I've profiled some legacy code I've inherited with cProfile. There were a bunch of
Using CMake I want to check if a particular function (cv::getGaborKernel) from OpenCV library

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.