Metadata-Version: 2.1
Name: jort
Version: 1.0.0
Summary: Script profiler with checkpoints
Home-page: https://github.com/bbrzycki/jort
Author: Bryan Brzycki
Author-email: bbrzycki@berkeley.edu
Project-URL: Source, https://github.com/bbrzycki/jort
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Description-Content-Type: text/markdown
License-File: LICENSE

# jort
[![PyPI version](https://badge.fury.io/py/jort.svg)](https://badge.fury.io/py/jort) 

Track, profile, and notify at custom checkpoints in your coding scripts

## Installation
```
pip install jort
```

## Usage
Use the `Tracker` to create named checkpoints throughout your code. Checkpoints need `start` and `stop` calls, and 
multiple iterations are combined to summarize how long it takes to complete each leg. The `report` function
prints the results from all checkpoints. If `stop` is not supplied a checkpoint name, the tracker will close and calculate elapsed time from the last open checkpoint (i.e. last in, first out).
```
import jort
from time import sleep

tr = jort.Tracker()

tr.start('my_script')
sleep(1)
for _ in range(10):
    tr.start('sleep_1s')
    sleep(1)
    tr.stop('sleep_1s')
tr.stop('my_script')
    
tr.report()
```

The printed report appears as:
```
my_script | 11.0 s ± 0.0 s per iteration, n = 1
sleep_1s | 1.0 s ± 0.0 s per iteration, n = 10
```

## Logging

`jort` automatically logs results by default. You can change the destination filename, as well as the level of verbosity: 0 - no logging, 1 - only elapsed times, 2 - start and stop times. Defaults are `logname='tracker.log'` and `verbose=2`.
```
import jort
from time import sleep

tr = jort.Tracker(logname='my_log.log', verbose=1)
```

## Function Decorators
`jort` also supports timing functions with decorators, via `Tracker.time_func`. Demonstrating on the first example:
```
tr = jort.Tracker()

@tr.time_func
def sleep_1s():
    sleep(1)
    
@tr.time_func
def my_script():
    sleep(1)
    for _ in range(10):
        sleep_1s()
        
tr.report()
```

The printed report appears as:
```
my_script | 11.0 s ± 0.0 s per iteration, n = 1
sleep_1s | 1.0 s ± 0.0 s per iteration, n = 10
```

## Future Directions

* Potential support for more complex profiling
