Search code examples
pythonwrapper

Python wrapper script to measure execution time of another python file


How can I make a python wrapper script that would measure the execution time of another script or another .py file using time?


Solution

  • You can use the timer module

    from timeit import default_timer as timer
    start = timer()
    function_you_want_to_time()
    # or import your script here
    # import script_to_time
    end = timer()
    elapsed = str(end - start)
    print(f'Run time in seconds: {elapsed}')