Skip to content

Instantly share code, notes, and snippets.

View nicholasmireles's full-sized avatar

Nicholas Mireles nicholasmireles

View GitHub Profile
@nicholasmireles
nicholasmireles / profiler.py
Created August 19, 2022 22:22
A one-line profiler: Simply add "import profiler" to your script
import cProfile
import inspect
import sys
# Ensure that we aren't being run directly
if __name__ != "__main__":
caller = None
# Look for the first actual .py filename
for frame in inspect.stack()[1:]: