Skip to content

Commit

Permalink
Merge pull request #111 from nschloe/remove-htmlhint
Browse files Browse the repository at this point in the history
Remove htmlhint
  • Loading branch information
nschloe authored Aug 10, 2021
2 parents cfda61b + 71d9728 commit cae3940
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 1,483 deletions.
13 changes: 0 additions & 13 deletions .eslintrc

This file was deleted.

50 changes: 18 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,35 @@ name: ci
on:
push:
branches:
- main
- main
pull_request:
branches:
- main
- main

jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v2
with:
python-version: "3.x"
- uses: actions/setup-node@v1
with:
node-version: "10.x"
- uses: actions/checkout@v2
- name: Lint with flake8
run: |
pip install flake8
flake8 .
- name: Lint with black
run: |
pip install black
black --check .
- name: Lint with npm
run: |
npm ci
npm run prettier
npm run htmlhint
- name: Check out repo
uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
- name: Run pre-commit
uses: pre-commit/action@v2.0.3

build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.6, 3.7, 3.8, 3.9]
steps:
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v2
- name: Test with tox
run: |
pip install tox
tox
- uses: codecov/codecov-action@v1
if: ${{ matrix.python-version == '3.9' }}
- uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- uses: actions/checkout@v2
- name: Test with tox
run: |
pip install tox
tox
- uses: codecov/codecov-action@v1
if: ${{ matrix.python-version == '3.9' }}
21 changes: 21 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.9.1
hooks:
- id: isort

- repo: https://github.com/python/black
rev: 21.6b0
hooks:
- id: black
language_version: python3

- repo: https://gitlab.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.3.2
hooks:
- id: prettier
42 changes: 0 additions & 42 deletions Makefile

This file was deleted.

21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,28 +24,33 @@ profiles, has minimal dependencies, uses [d3](https://d3js.org/) and
below) and is faster, too.

Create a runtime profile with

```
python -mcProfile -o program.prof yourfile.py
```

or an [import
profile](https://docs.python.org/3/using/cmdline.html#envvar-PYTHONPROFILEIMPORTTIME)
with

```
python -X importtime yourfile.py 2> import.log
```

and show it with

```
tuna program.prof
```

![](https://nschloe.github.io/tuna/screencast.gif)


### Why tuna doesn't show the whole call tree

The whole timed call tree _cannot_ be retrieved from profile data. Python developers
made the decision to only store _parent data_ in profiles because it can be computed
with little overhead. To illustrate, consider the following program.

```python
import time

Expand All @@ -71,6 +76,7 @@ if __name__ == "__main__":
a(4, 1)
b()
```

The root process (`__main__`) calls `a()` which spends 4 seconds in `c()` and 1 second
in `d()`. `__main__` also calls `b()` which calls `a()`, this time spending 1 second in
`c()` and 4 seconds in `d()`. The profile, however, will only store that `c()` spent a
Expand All @@ -82,23 +88,25 @@ tuna only displays the part of the timed call tree that can be deduced from the
SnakeViz, on the other hand, tries to construct the entire call tree, but ends up
providing lots of _wrong_ timings.

| ![](https://nschloe.github.io/tuna/snakeviz-example-wrong.png) | ![](https://nschloe.github.io/tuna/foo.png) |
|:----:|:----:|
| SnakeViz output. **Wrong.** | tuna output. Only shows what can be retrieved from the profile. |
| ![](https://nschloe.github.io/tuna/snakeviz-example-wrong.png) | ![](https://nschloe.github.io/tuna/foo.png) |
| :------------------------------------------------------------: | :-------------------------------------------------------------: |
| SnakeViz output. **Wrong.** | tuna output. Only shows what can be retrieved from the profile. |

### Installation

tuna is [available from the Python Package Index](https://pypi.org/project/tuna/), so
simply do

```
pip install tuna
```
to install.

to install.

### Testing

To run the tuna unit tests, check out this repository and type

```
pytest
```
Expand All @@ -108,10 +116,12 @@ pytest
tuna includes a `tuna` line / cell magic which can be used as a drop-in replacement for
the `prun` magic. Simply run `%load_ext tuna` to load the magic and then call it like
`%tuna sleep(3)` or

```python
%%tuna
sleep(3)
```

`prun` is still used to do the actual profiling and then the results are displayed in
the notebook.

Expand All @@ -121,4 +131,5 @@ After forking and cloning the repository, make sure to run `make dep` to install
additional dependencies (bootstrap and d3) which aren't stored in the repo.

### License

This software is published under the [GPLv3 license](https://www.gnu.org/licenses/gpl-3.0.en.html).
5 changes: 2 additions & 3 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ publish: tag upload

clean:
@find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf
@rm -rf src/*.egg-info/ build/ dist/ .tox/
@rm -rf *.egg-info/ src/*.egg-info/ build/ dist/ .tox/

dep:
npm install
Expand All @@ -36,9 +36,8 @@ lint:
black --check .
# blacken-docs README.md
npm run prettier
npm run htmlhint

format:
isort .
black .
prettier --write tuna/web/static/icicle.js
prettier --write README.md .github tuna/web/static/icicle.js tuna/web/static/tuna.css tuna/web/index.html
Loading

0 comments on commit cae3940

Please sign in to comment.