-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 2a99d0e
Showing
10 changed files
with
547 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
*.pyc | ||
*.db | ||
*.scssc | ||
*.map | ||
*.idea | ||
media | ||
|
||
# Created by https://www.gitignore.io/api/python | ||
|
||
### Python ### | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
### Python Patch ### | ||
.venv/ | ||
|
||
### Python.VirtualEnv Stack ### | ||
# Virtualenv | ||
# http://iamzed.com/2009/05/07/a-primer-on-virtualenv/ | ||
[Bb]in | ||
[Ii]nclude | ||
[Ll]ib | ||
[Ll]ib64 | ||
[Ll]ocal | ||
[Ss]cripts | ||
pyvenv.cfg | ||
pip-selfcheck.json | ||
|
||
# End of https://www.gitignore.io/api/python |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
repos: | ||
- repo: https://github.com/psf/black | ||
rev: 23.9.1 | ||
hooks: | ||
- id: black | ||
|
||
- repo: https://github.com/PyCQA/isort | ||
rev: 5.12.0 | ||
hooks: | ||
- id: isort | ||
args: ["--profile", "black", "--filter-files"] | ||
|
||
- repo: https://github.com/hakancelikdev/unimport | ||
rev: 1.0.0 | ||
hooks: | ||
- id: unimport | ||
args: [--remove, --include-star-import] | ||
|
||
- repo: https://github.com/pre-commit/mirrors-mypy | ||
rev: v1.5.1 | ||
hooks: | ||
- id: mypy | ||
exclude: docs | ||
args: | ||
[ | ||
--ignore-missing-imports, | ||
--show-error-codes, | ||
--disallow-incomplete-defs, | ||
--explicit-package-bases, | ||
] | ||
additional_dependencies: [types-toml==0.1.3] | ||
|
||
- repo: https://github.com/PyCQA/docformatter | ||
rev: v1.7.5 | ||
hooks: | ||
- id: docformatter | ||
args: [--in-place] | ||
|
||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v3.0.3 | ||
hooks: | ||
- id: prettier | ||
args: [--prose-wrap=always, --print-width=88] | ||
|
||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.4.0 | ||
hooks: | ||
- id: end-of-file-fixer | ||
files: "\\.(py|.txt|.yaml|.json|.in|.md|.toml|.cfg|.html|.yml)$" | ||
|
||
- repo: local | ||
hooks: | ||
- id: unittests | ||
name: run unit tests | ||
entry: python -m unittest | ||
language: system | ||
pass_filenames: false | ||
args: ["discover"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
The MIT License (MIT) | ||
===================== | ||
|
||
Copyright © `2023` `Furkan Onder` | ||
|
||
Permission is hereby granted, free of charge, to any person | ||
obtaining a copy of this software and associated documentation | ||
files (the “Software”), to deal in the Software without | ||
restriction, including without limitation the rights to use, | ||
copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the | ||
Software is furnished to do so, subject to the following | ||
conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | ||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
_akarsu_ is the New Generation Profiler based on | ||
[PEP 669](https://peps.python.org/pep-0669/). The name of the project, comes from the | ||
surname of a minstrel named `Muhlis Akarsu`, which means `stream`. | ||
|
||
## Installation | ||
|
||
_akarsu_ can be installed by running `pip install akarsu`. It requires Python 3.12.0+ to | ||
run. | ||
|
||
## Usage | ||
|
||
```sh | ||
cat example.py | ||
``` | ||
|
||
Output: | ||
|
||
```python | ||
def foo(): | ||
x = 1 | ||
isinstance(x, int) | ||
return x | ||
|
||
|
||
def bar(): | ||
foo() | ||
|
||
|
||
bar() | ||
``` | ||
|
||
--- | ||
|
||
```sh | ||
akarsu -f example.py | ||
``` | ||
|
||
Output: | ||
|
||
``` | ||
Count Event Type Filename(function) | ||
1 PY_CALL example.py(bar) | ||
1 PY_START example.py(bar) | ||
1 PY_CALL example.py(foo) | ||
1 PY_START example.py(foo) | ||
1 C_CALL example.py(<built-in function isinstance>) | ||
1 C_RETURN example.py(foo) | ||
1 PY_RETURN example.py(foo) | ||
1 PY_RETURN example.py(bar) | ||
Total number of events: 8 | ||
PY_CALL = 2 | ||
PY_START = 2 | ||
PY_RETURN = 2 | ||
C_CALL = 1 | ||
C_RETURN = 1 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
[build-system] | ||
requires = ["setuptools"] | ||
build-backend = "setuptools.build_meta" | ||
|
||
[project] | ||
name = "akarsu" | ||
version = "0.1.0" | ||
description = "New Generation Profiler based on PEP 669" | ||
readme = "README.md" | ||
requires-python = ">=3.12" | ||
license = {file = "LICENSE.txt"} | ||
keywords = ["profiler", "PEP669"] | ||
authors = [ | ||
{ name = "Furkan Onder", email = "[email protected]" }, | ||
] | ||
classifiers = [ | ||
"Development Status :: 3 - Alpha", | ||
"Environment :: Console", | ||
"Intended Audience :: Developers", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
"Programming Language :: Python", | ||
"Programming Language :: Python :: 3 :: Only", | ||
"Programming Language :: Python :: 3.12", | ||
"Topic :: Software Development :: Libraries :: Python Modules", | ||
] | ||
|
||
[project.urls] | ||
"Homepage" = "https://github.com/furkanonder/akarsu" | ||
"Bug Reports" = "https://github.com/furkanonder/akarsu/issues" | ||
"Source" = "https://github.com/furkanonder/akarsu" | ||
|
||
[project.scripts] | ||
akarsu = "akarsu.__main__:main" | ||
|
||
[tool.black] | ||
target-version = ["py312"] | ||
preview = true | ||
|
||
[tool.isort] | ||
profile = "black" | ||
|
||
[tool.docformatter] | ||
recursive = true | ||
wrap-summaries = 79 | ||
wrap-descriptions = 79 | ||
blank = true | ||
|
||
[tool.mypy] | ||
warn_unused_configs = true | ||
no_strict_optional = true | ||
ignore_missing_imports = true | ||
show_error_codes = true |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import argparse | ||
import io | ||
from collections import Counter | ||
|
||
from akarsu.akarsu import Akarsu | ||
|
||
|
||
def main() -> None: | ||
parser = argparse.ArgumentParser( | ||
description="New Generation Profiler based on PEP 669" | ||
) | ||
parser.add_argument("-v", "--version", action="version", version="0.1.0") | ||
parser.add_argument("-f", "--file", type=str, help="Path to the file") | ||
args = parser.parse_args() | ||
|
||
if file := args.file: | ||
with io.open(file) as fp: | ||
source = fp.read() | ||
events = Akarsu(source, args.file).profile() | ||
counter: Counter = Counter() | ||
|
||
print(f"{'Count':>10}{'Event Type':^20}{'Filename(function)':<50}") | ||
for event, count in Counter(events).most_common(): | ||
event_type, file_name, func_name = event | ||
counter[event_type] += 1 | ||
print(f"{count:>10}{event_type:^20}{f'{file_name}({func_name})':<50}") | ||
|
||
print(f"\nTotal number of events: {counter.total()}") | ||
for event_type, count in counter.most_common(): | ||
print(f" {event_type} = {count}") | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
Oops, something went wrong.