question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pprofile style context profiling

See original GitHub issue

I’m usually not interested in profiling an entire program, I’m more interested in profiling some hotspot of code, or just some new piece of code.

pprofile allows for just profiling a specific region of code (from pprofile’s main page):

def someOtherHotSpotCallable():
    # Statistic profiler
    prof = pprofile.StatisticalProfile()
    with prof(
        period=0.001, # Sample every 1ms
        single=True, # Only sample current thread
    ):
        # Code to profile
    prof.print_stats()

It would be nice if scalene allowed for such granularity.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:17 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
ClemensA4t1qbitcommented, Oct 29, 2020

My bad; I used from scalene import profile, but the trick is to, as you say, just use @profile. I was just a bit confused because my IDE complained that in that case profile isn’t defined anywhere.

I changed it (removed my import) and it does seem to work.

PS: I loved your ACM Tech Talk. So many spot-on Simpsons references.

1reaction
emerybergercommented, Oct 24, 2020

UPDATE: As of version 1.1.5, Scalene now supports @profile decorators.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Relationship between Profile, Context and Preference
Figure 1 shows a comprehensive and iterative profiling process for personalisation, in four stages of information collection of user data, initialisation of the ......
Read more >
The Python Profilers — Python 3.11.1 documentation
cProfile and profile provide deterministic profiling of Python programs. ... context manager (supported only in cProfile module. see Context Manager Types):.
Read more >
Baseline Profiles - Android Developers
You can see this code in full context and more detail as part of our performance samples on GitHub. What to include. When...
Read more >
Profiler API - React
The Profiler measures how often a React application renders and what the “cost” of rendering is. Its purpose is to help identify parts...
Read more >
People, Profiles and Users - conf.researchr.org - Read the Docs
When profile information is shown in the context of that past conference, it will always reflect someone's bio/affiliation at the time/in the context...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found