Metadata-Version: 2.1
Name: py-ticktock
Version: 0.0.3
Summary: Simple Python code metering library.
Home-page: UNKNOWN
License: UNKNOWN
Project-URL: Bug Tracker, https://github.com/victorbenichoux/ticktock/issues
Project-URL: Documentation, https://victorbenichoux.github.io/tickto/
Project-URL: Source Code, https://github.com/victorbenichoux/ticktock
Platform: UNKNOWN
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Description-Content-Type: text/markdown

</p>
<h1 align="center"> ticktock </h1>
<p align="center">
  <em>Simple Python code metering library.</em>
</p>

---
`ticktock` is a minimalist library to view Python time performance of Python code.

First, install `ticktock`:
```
pip install py-ticktock
```

Then, anywhere in your code you can use `tick` to start a clock, and `tock` to register the end of the snippet you want to time:

```python
t = tick()
# do some work
t.tock()
```

Even if the code is called many times within a loop, measured times will only periodially (2 seconds by default):

```python
import time
from ticktock import tick

for _ in range(1000):
    t = tick()
    # do some work
    time.sleep(1)
    t.tock()
```

You can create multiple independent ticks, which will appear as two separate clocks:

```python
for _ in range(1000):
    t = tick()
    # do some work
    time.sleep(1)
    t.tock()

    t = tick()
    # do some other work
    time.sleep(0.5)
    t.tock()
```

Ticks can share a common starting point:

```python
for k in range(1000):
    t = tick()
    # do some work
    time.sleep(1)
    if k % 2 == 1:
        time.sleep(1)
        t.tock()
    else:
        t.tock()
```

It is also possible to use `ticktock` as a context manager to track the timing of a chunk of code:

```python
from ticktock import ticktock

with ticktock():
    time.sleep(1)
```

Or a decorator, to track the timing of each call to a function:

```python
from ticktock import ticktock

@ticktock
def f():
    time.sleep(1)

f()
```


