Profiling Streamlit code

Is there a way to attach a profiler to a Streamlit app to detect which part of the code is running slowly? I suspect it is with one of my data processing functions, not with the Streamlit display itself.

If you haven’t done it yet, put all the code in your main file inside a main() function. Then add code that calls the function using the profiler in the standard library:

import cProfiler


def main():
    # your streamlit app here
    ...


if __name__ == "__main__":
    cProfiler.run("main()") 

Learn more about what you can do with the profiler and its output:

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.