Skip to content

Support real method profiling out-of-the-box #5

@pabloyoyoista

Description

@pabloyoyoista

We've been using cProfile from python quite successfully. And the changes required for a method to be profiled have been mostly minimal.

The can be summarized in:

I managed to execute this in a custom way by renaming analysis and/or synthesis to run_analysis and run_synthesis. e.g:

Introducing the profiling analysis as this:

def analysis(sliceno, prepare_res):                                                                                                                                                                                
    cProfile.runctx(                                                                                                                                                                                               
        'run_analysis(sliceno, prepare_res)',                                                                                                                                                                      
        globals(),                                                                                                                                                                                                 
        locals(),                                                                                                                                                                                                  
        filename=f"profile.{sliceno}"                                                                                                                                                            
    )

And then aggregating and printing the results in synthesis:

def synthesis(slices):                                                                                                                                                                                                                                                                                                                                                                                  
    stats = pstats.Stats()                                                                                                                                                                                         
    for i in range(slices):                                                                                                                                                                                        
        stats.add(f"profile-{options.new_col}.{i}")                                                                                                                                                                
    stats.sort_stats('cumulative')                                                                                                                                                                                 
    #stats.print_stats()                                                                                                                                                                                           
    stats.print_callers() 

I believe being able to do this out-of-the-box from urd.build would be an extraordinary feature. We would certainly need to expose some way to print the statistics in the urd.build, for which I'd need some input. Otherwise I'd be quite happy to work on this implementation if deemed reasonable

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions