profiling-explorer 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. profiling_explorer-1.0.0/CHANGELOG.rst +8 -0
  2. profiling_explorer-1.0.0/LICENSE +21 -0
  3. profiling_explorer-1.0.0/MANIFEST.in +8 -0
  4. profiling_explorer-1.0.0/PKG-INFO +150 -0
  5. profiling_explorer-1.0.0/README.rst +123 -0
  6. profiling_explorer-1.0.0/pyproject.toml +134 -0
  7. profiling_explorer-1.0.0/setup.cfg +4 -0
  8. profiling_explorer-1.0.0/src/profiling_explorer/__init__.py +0 -0
  9. profiling_explorer-1.0.0/src/profiling_explorer/__main__.py +6 -0
  10. profiling_explorer-1.0.0/src/profiling_explorer/main.py +56 -0
  11. profiling_explorer-1.0.0/src/profiling_explorer/management/__init__.py +0 -0
  12. profiling_explorer-1.0.0/src/profiling_explorer/management/commands/__init__.py +0 -0
  13. profiling_explorer-1.0.0/src/profiling_explorer/management/commands/runserver.py +28 -0
  14. profiling_explorer-1.0.0/src/profiling_explorer/py.typed +0 -0
  15. profiling_explorer-1.0.0/src/profiling_explorer/settings.py +37 -0
  16. profiling_explorer-1.0.0/src/profiling_explorer/static/script.js +84 -0
  17. profiling_explorer-1.0.0/src/profiling_explorer/static/styles.css +281 -0
  18. profiling_explorer-1.0.0/src/profiling_explorer/templates/_row.html +9 -0
  19. profiling_explorer-1.0.0/src/profiling_explorer/templates/base.html +27 -0
  20. profiling_explorer-1.0.0/src/profiling_explorer/templates/callers_callees.html +30 -0
  21. profiling_explorer-1.0.0/src/profiling_explorer/templates/index.html +23 -0
  22. profiling_explorer-1.0.0/src/profiling_explorer/templatetags/__init__.py +0 -0
  23. profiling_explorer-1.0.0/src/profiling_explorer/templatetags/profiling_explorer_tags.py +24 -0
  24. profiling_explorer-1.0.0/src/profiling_explorer/urls.py +14 -0
  25. profiling_explorer-1.0.0/src/profiling_explorer/views.py +330 -0
  26. profiling_explorer-1.0.0/src/profiling_explorer.egg-info/PKG-INFO +150 -0
  27. profiling_explorer-1.0.0/src/profiling_explorer.egg-info/SOURCES.txt +29 -0
  28. profiling_explorer-1.0.0/src/profiling_explorer.egg-info/dependency_links.txt +1 -0
  29. profiling_explorer-1.0.0/src/profiling_explorer.egg-info/entry_points.txt +2 -0
  30. profiling_explorer-1.0.0/src/profiling_explorer.egg-info/requires.txt +1 -0
  31. profiling_explorer-1.0.0/src/profiling_explorer.egg-info/top_level.txt +1 -0
@@ -0,0 +1,8 @@
1
+ =========
2
+ Changelog
3
+ =========
4
+
5
+ 1.0.0 (2026-04-02)
6
+ ------------------
7
+
8
+ * Initial release.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Adam Johnson
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,8 @@
1
+ prune tests
2
+ include CHANGELOG.rst
3
+ include LICENSE
4
+ include pyproject.toml
5
+ include README.rst
6
+ include src/*/py.typed
7
+ graft src/profiling_explorer/static/
8
+ graft src/profiling_explorer/templates/
@@ -0,0 +1,150 @@
1
+ Metadata-Version: 2.4
2
+ Name: profiling-explorer
3
+ Version: 1.0.0
4
+ Summary: Table-based exploration tool for Python profiling data (pstats files).
5
+ Author-email: Adam Johnson <me@adamj.eu>
6
+ License-Expression: MIT
7
+ Project-URL: Changelog, https://github.com/adamchainz/profiling-explorer/blob/main/CHANGELOG.rst
8
+ Project-URL: Funding, https://adamj.eu/books/
9
+ Project-URL: Repository, https://github.com/adamchainz/profiling-explorer
10
+ Keywords: profiler,profiling,pstats
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Natural Language :: English
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3 :: Only
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Programming Language :: Python :: 3.13
20
+ Classifier: Programming Language :: Python :: 3.14
21
+ Classifier: Typing :: Typed
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/x-rst
24
+ License-File: LICENSE
25
+ Requires-Dist: django>=5.2
26
+ Dynamic: license-file
27
+
28
+ ==================
29
+ profiling-explorer
30
+ ==================
31
+
32
+ .. image:: https://img.shields.io/github/actions/workflow/status/adamchainz/profiling-explorer/main.yml.svg?branch=main&style=for-the-badge
33
+ :target: https://github.com/adamchainz/profiling-explorer/actions?workflow=CI
34
+
35
+ .. image:: https://img.shields.io/badge/Coverage-70%25-success?style=for-the-badge
36
+ :target: https://github.com/adamchainz/profiling-explorer/actions?workflow=CI
37
+
38
+ .. image:: https://img.shields.io/pypi/v/profiling-explorer.svg?style=for-the-badge
39
+ :target: https://pypi.org/project/profiling-explorer/
40
+
41
+ .. image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge
42
+ :target: https://github.com/psf/black
43
+
44
+ .. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=for-the-badge
45
+ :target: https://github.com/pre-commit/pre-commit
46
+ :alt: pre-commit
47
+
48
+ ----
49
+
50
+ Table-based exploration tool for Python profiling data (pstats files).
51
+
52
+ .. Generated with:
53
+ .. uvx --with django python -m cProfile -o django_utils_html.pstats -m django.utils.html
54
+ .. uvr profiling-explorer django_utils_html.pstats
55
+ .. …then in another tab:
56
+ .. uvx shot-scraper --width 1280 --height 720 --retina --wait 1000 http://127.0.0.1:8099/ -o screenshot.png
57
+
58
+ .. figure:: https://raw.githubusercontent.com/adamchainz/profiling-explorer/screenshot/screenshot.png
59
+ :alt: profiling-explorer screenshot
60
+
61
+ ----
62
+
63
+ **Get better at command line Git** with my book `Boost Your Git DX <https://adamchainz.gumroad.com/l/bygdx>`__.
64
+
65
+ ----
66
+
67
+ Requirements
68
+ ------------
69
+
70
+ Python 3.10 to 3.14 supported.
71
+
72
+ Installation
73
+ ------------
74
+
75
+ 1. Install with **pip**:
76
+
77
+ .. code-block:: sh
78
+
79
+ python -m pip install profiling-explorer
80
+
81
+ Usage
82
+ -----
83
+
84
+ ``profiling-explorer`` reads |pstats|__ files as generated by Python’s profilers: |profiling.tracing|__ (called ``cProfile`` on Python < 3.15) and |profiling.sampling|__ (new in Python 3.15).
85
+ To use it, first generate a profile file, for example by running your program under cProfile:
86
+
87
+ .. |pstats| replace:: ``pstats``
88
+ __ https://docs.python.org/3.15/library/pstats.html
89
+
90
+ .. |profiling.tracing| replace:: ``profiling.tracing``
91
+ __ https://docs.python.org/3.15/library/profiling.tracing.html
92
+
93
+ .. |profiling.sampling| replace:: ``profiling.sampling``
94
+ __ https://docs.python.org/3.15/library/profiling.sampling.html
95
+
96
+ .. code-block:: console
97
+
98
+ $ python -m cProfile -o example.pstats example.py
99
+
100
+ (Also runnable as ``python -m profiling.tracing`` instead on Python 3.15+.)
101
+
102
+ Then run ``profiling-explorer`` with the generated file:
103
+
104
+ .. code-block:: console
105
+
106
+ $ profiling-explorer example.pstats
107
+
108
+ The report will open in your web browser, and you can explore the profile data with the interactive interface.
109
+ Features:
110
+
111
+ * Click the **calls**, **internal ms**, or **cumulative ms** column headers to sort by that column.
112
+ * Use the search box to filter by filename or function name.
113
+ * Hover by a filename + line number pair to reveal the copy button, which copies the location to your clipboard for faster opening.
114
+ * Click the **callers** or **callees** links on the right of a row to see the callers or callees of that function.
115
+
116
+ Full help:
117
+
118
+ .. [[[cog
119
+ .. import cog
120
+ .. import subprocess
121
+ .. import sys
122
+ .. result = subprocess.run(
123
+ .. [sys.executable, "-m", "profiling_explorer", "--help"],
124
+ .. capture_output=True,
125
+ .. text=True,
126
+ .. )
127
+ .. cog.outl("")
128
+ .. cog.outl(".. code-block:: console")
129
+ .. cog.outl("")
130
+ .. for line in result.stdout.splitlines():
131
+ .. if line.strip() == "":
132
+ .. cog.outl("")
133
+ .. else:
134
+ .. cog.outl(" " + line.rstrip())
135
+ .. cog.outl("")
136
+ .. ]]]
137
+
138
+ .. code-block:: console
139
+
140
+ usage: profiling-explorer [-h] [--port PORT] [--dev] FILE
141
+
142
+ positional arguments:
143
+ FILE The pstats data file to explore.
144
+
145
+ options:
146
+ -h, --help show this help message and exit
147
+ --port PORT Port for the local web server (default: 8099).
148
+ --dev Run in development mode (enables server reload and debug mode).
149
+
150
+ .. [[[end]]]
@@ -0,0 +1,123 @@
1
+ ==================
2
+ profiling-explorer
3
+ ==================
4
+
5
+ .. image:: https://img.shields.io/github/actions/workflow/status/adamchainz/profiling-explorer/main.yml.svg?branch=main&style=for-the-badge
6
+ :target: https://github.com/adamchainz/profiling-explorer/actions?workflow=CI
7
+
8
+ .. image:: https://img.shields.io/badge/Coverage-70%25-success?style=for-the-badge
9
+ :target: https://github.com/adamchainz/profiling-explorer/actions?workflow=CI
10
+
11
+ .. image:: https://img.shields.io/pypi/v/profiling-explorer.svg?style=for-the-badge
12
+ :target: https://pypi.org/project/profiling-explorer/
13
+
14
+ .. image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=for-the-badge
15
+ :target: https://github.com/psf/black
16
+
17
+ .. image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white&style=for-the-badge
18
+ :target: https://github.com/pre-commit/pre-commit
19
+ :alt: pre-commit
20
+
21
+ ----
22
+
23
+ Table-based exploration tool for Python profiling data (pstats files).
24
+
25
+ .. Generated with:
26
+ .. uvx --with django python -m cProfile -o django_utils_html.pstats -m django.utils.html
27
+ .. uvr profiling-explorer django_utils_html.pstats
28
+ .. …then in another tab:
29
+ .. uvx shot-scraper --width 1280 --height 720 --retina --wait 1000 http://127.0.0.1:8099/ -o screenshot.png
30
+
31
+ .. figure:: https://raw.githubusercontent.com/adamchainz/profiling-explorer/screenshot/screenshot.png
32
+ :alt: profiling-explorer screenshot
33
+
34
+ ----
35
+
36
+ **Get better at command line Git** with my book `Boost Your Git DX <https://adamchainz.gumroad.com/l/bygdx>`__.
37
+
38
+ ----
39
+
40
+ Requirements
41
+ ------------
42
+
43
+ Python 3.10 to 3.14 supported.
44
+
45
+ Installation
46
+ ------------
47
+
48
+ 1. Install with **pip**:
49
+
50
+ .. code-block:: sh
51
+
52
+ python -m pip install profiling-explorer
53
+
54
+ Usage
55
+ -----
56
+
57
+ ``profiling-explorer`` reads |pstats|__ files as generated by Python’s profilers: |profiling.tracing|__ (called ``cProfile`` on Python < 3.15) and |profiling.sampling|__ (new in Python 3.15).
58
+ To use it, first generate a profile file, for example by running your program under cProfile:
59
+
60
+ .. |pstats| replace:: ``pstats``
61
+ __ https://docs.python.org/3.15/library/pstats.html
62
+
63
+ .. |profiling.tracing| replace:: ``profiling.tracing``
64
+ __ https://docs.python.org/3.15/library/profiling.tracing.html
65
+
66
+ .. |profiling.sampling| replace:: ``profiling.sampling``
67
+ __ https://docs.python.org/3.15/library/profiling.sampling.html
68
+
69
+ .. code-block:: console
70
+
71
+ $ python -m cProfile -o example.pstats example.py
72
+
73
+ (Also runnable as ``python -m profiling.tracing`` instead on Python 3.15+.)
74
+
75
+ Then run ``profiling-explorer`` with the generated file:
76
+
77
+ .. code-block:: console
78
+
79
+ $ profiling-explorer example.pstats
80
+
81
+ The report will open in your web browser, and you can explore the profile data with the interactive interface.
82
+ Features:
83
+
84
+ * Click the **calls**, **internal ms**, or **cumulative ms** column headers to sort by that column.
85
+ * Use the search box to filter by filename or function name.
86
+ * Hover by a filename + line number pair to reveal the copy button, which copies the location to your clipboard for faster opening.
87
+ * Click the **callers** or **callees** links on the right of a row to see the callers or callees of that function.
88
+
89
+ Full help:
90
+
91
+ .. [[[cog
92
+ .. import cog
93
+ .. import subprocess
94
+ .. import sys
95
+ .. result = subprocess.run(
96
+ .. [sys.executable, "-m", "profiling_explorer", "--help"],
97
+ .. capture_output=True,
98
+ .. text=True,
99
+ .. )
100
+ .. cog.outl("")
101
+ .. cog.outl(".. code-block:: console")
102
+ .. cog.outl("")
103
+ .. for line in result.stdout.splitlines():
104
+ .. if line.strip() == "":
105
+ .. cog.outl("")
106
+ .. else:
107
+ .. cog.outl(" " + line.rstrip())
108
+ .. cog.outl("")
109
+ .. ]]]
110
+
111
+ .. code-block:: console
112
+
113
+ usage: profiling-explorer [-h] [--port PORT] [--dev] FILE
114
+
115
+ positional arguments:
116
+ FILE The pstats data file to explore.
117
+
118
+ options:
119
+ -h, --help show this help message and exit
120
+ --port PORT Port for the local web server (default: 8099).
121
+ --dev Run in development mode (enables server reload and debug mode).
122
+
123
+ .. [[[end]]]
@@ -0,0 +1,134 @@
1
+ [build-system]
2
+ build-backend = "setuptools.build_meta"
3
+ requires = [
4
+ "setuptools>=77",
5
+ ]
6
+
7
+ [project]
8
+ name = "profiling-explorer"
9
+ version = "1.0.0"
10
+ description = "Table-based exploration tool for Python profiling data (pstats files)."
11
+ readme = "README.rst"
12
+ keywords = [
13
+ "profiler",
14
+ "profiling",
15
+ "pstats",
16
+ ]
17
+ license = "MIT"
18
+ license-files = [ "LICENSE" ]
19
+ authors = [
20
+ { name = "Adam Johnson", email = "me@adamj.eu" },
21
+ ]
22
+ requires-python = ">=3.10"
23
+ classifiers = [
24
+ "Development Status :: 5 - Production/Stable",
25
+ "Intended Audience :: Developers",
26
+ "Natural Language :: English",
27
+ "Operating System :: OS Independent",
28
+ "Programming Language :: Python :: 3 :: Only",
29
+ "Programming Language :: Python :: 3.10",
30
+ "Programming Language :: Python :: 3.11",
31
+ "Programming Language :: Python :: 3.12",
32
+ "Programming Language :: Python :: 3.13",
33
+ "Programming Language :: Python :: 3.14",
34
+ "Typing :: Typed",
35
+ ]
36
+ dependencies = [
37
+ "django>=5.2",
38
+ ]
39
+ urls.Changelog = "https://github.com/adamchainz/profiling-explorer/blob/main/CHANGELOG.rst"
40
+ urls.Funding = "https://adamj.eu/books/"
41
+ urls.Repository = "https://github.com/adamchainz/profiling-explorer"
42
+ scripts.profiling-explorer = "profiling_explorer.main:main"
43
+
44
+ [dependency-groups]
45
+ test = [
46
+ "cogapp>=3.6",
47
+ "coverage[toml]",
48
+ "pytest",
49
+ "pytest-django",
50
+ "pytest-randomly",
51
+ ]
52
+
53
+ [tool.ruff]
54
+ lint.select = [
55
+ # flake8-bugbear
56
+ "B",
57
+ # flake8-comprehensions
58
+ "C4",
59
+ # pycodestyle
60
+ "E",
61
+ # Pyflakes errors
62
+ "F",
63
+ # isort
64
+ "I",
65
+ # flake8-simplify
66
+ "SIM",
67
+ # flake8-tidy-imports
68
+ "TID",
69
+ # pyupgrade
70
+ "UP",
71
+ # Pyflakes warnings
72
+ "W",
73
+ ]
74
+ lint.ignore = [
75
+ # flake8-bugbear opinionated rules
76
+ "B9",
77
+ # line-too-long
78
+ "E501",
79
+ # suppressible-exception
80
+ "SIM105",
81
+ # if-else-block-instead-of-if-exp
82
+ "SIM108",
83
+ ]
84
+ lint.extend-safe-fixes = [
85
+ # non-pep585-annotation
86
+ "UP006",
87
+ ]
88
+ lint.isort.required-imports = [ "from __future__ import annotations" ]
89
+
90
+ [tool.pyproject-fmt]
91
+ max_supported_python = "3.14"
92
+
93
+ [tool.pytest]
94
+ ini_options.addopts = """\
95
+ --strict-config
96
+ --strict-markers
97
+ --ds=profiling_explorer.settings
98
+ """
99
+ ini_options.django_find_project = false
100
+ ini_options.xfail_strict = true
101
+
102
+ [tool.coverage]
103
+ run.branch = true
104
+ run.data_file = ".coverage/cov"
105
+ run.parallel = true
106
+ run.source = [
107
+ "profiling_explorer",
108
+ "tests",
109
+ ]
110
+ paths.source = [
111
+ "src",
112
+ ".tox/**/site-packages",
113
+ ]
114
+ report.exclude_also = [
115
+ "if TYPE_CHECKING:",
116
+ ]
117
+ report.show_missing = true
118
+ report.skip_covered = true
119
+ report.skip_empty = true
120
+
121
+ [tool.mypy]
122
+ enable_error_code = [
123
+ "ignore-without-code",
124
+ "redundant-expr",
125
+ "truthy-bool",
126
+ ]
127
+ mypy_path = "src/"
128
+ namespace_packages = false
129
+ strict = true
130
+ warn_unreachable = true
131
+ overrides = [ { module = "tests.*", allow_untyped_defs = true } ]
132
+
133
+ [tool.rstcheck]
134
+ report_level = "ERROR"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,6 @@
1
+ from __future__ import annotations
2
+
3
+ from profiling_explorer.main import main
4
+
5
+ if __name__ == "__main__": # pragma: no cover
6
+ raise SystemExit(main())
@@ -0,0 +1,56 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import os
5
+ import pstats
6
+ import sys
7
+ from collections.abc import Sequence
8
+
9
+ import django
10
+ from django.core.management import call_command
11
+
12
+ from profiling_explorer import settings, views
13
+
14
+
15
+ def main(argv: Sequence[str] | None = None) -> int:
16
+ if argv is None:
17
+ argv = sys.argv[1:]
18
+
19
+ parser = argparse.ArgumentParser(prog="profiling-explorer", allow_abbrev=False)
20
+ parser.suggest_on_error = True # type: ignore[attr-defined]
21
+ parser.add_argument(
22
+ "filename",
23
+ metavar="FILE",
24
+ help="The pstats data file to explore.",
25
+ )
26
+ parser.add_argument(
27
+ "--port",
28
+ type=int,
29
+ default=8099,
30
+ metavar="PORT",
31
+ help="Port for the local web server (default: 8099).",
32
+ )
33
+ parser.add_argument(
34
+ "--dev",
35
+ action="store_true",
36
+ default=False,
37
+ help="Run in development mode (enables server reload and debug mode).",
38
+ )
39
+ args = parser.parse_args(argv)
40
+
41
+ settings.DEBUG = args.dev # type: ignore[attr-defined]
42
+
43
+ views.profile = views.build_profile(pstats.Stats(args.filename), args.filename)
44
+
45
+ os.environ["DJANGO_SETTINGS_MODULE"] = "profiling_explorer.settings"
46
+
47
+ django.setup()
48
+
49
+ call_command(
50
+ "runserver",
51
+ f"127.0.0.1:{args.port}",
52
+ "--nothreading",
53
+ *(() if args.dev else ("--noreload",)),
54
+ )
55
+
56
+ return 0
@@ -0,0 +1,28 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ import webbrowser
5
+ from typing import Any
6
+
7
+ from django.core.management.commands.runserver import Command as RunserverCommand
8
+ from django.utils.log import RequireDebugTrue
9
+
10
+ logger = logging.getLogger("django.server")
11
+ logger.filters.append(RequireDebugTrue())
12
+
13
+
14
+ class Command(RunserverCommand):
15
+ addr: str
16
+
17
+ def handle(self, *args: Any, **options: Any) -> None:
18
+ self.use_reloader = options["use_reloader"]
19
+ super().handle(*args, **options)
20
+
21
+ def on_bind(self, server_port: int) -> None:
22
+ self.stdout.write(
23
+ f"profiling-explorer running at http://{self.addr}:{server_port}/\n"
24
+ "Press CTRL+C to quit."
25
+ )
26
+ if not self.use_reloader:
27
+ print("Opening in web browser…")
28
+ webbrowser.open(f"http://{self.addr}:{server_port}")
@@ -0,0 +1,37 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+
5
+ # Hide development server warning
6
+ # https://docs.djangoproject.com/en/stable/ref/django-admin/#envvar-DJANGO_RUNSERVER_HIDE_WARNING
7
+ os.environ["DJANGO_RUNSERVER_HIDE_WARNING"] = "true"
8
+
9
+ # Disable host header validation
10
+ ALLOWED_HOSTS = ["*"]
11
+
12
+ INSTALLED_APPS = [
13
+ "profiling_explorer",
14
+ "django.contrib.humanize",
15
+ ]
16
+
17
+ MIDDLEWARE = [
18
+ "django.middleware.common.CommonMiddleware",
19
+ ]
20
+
21
+ ROOT_URLCONF = "profiling_explorer.urls"
22
+
23
+ SECRET_KEY = "we-dont-use-any-secret-features-so-whatever"
24
+
25
+ TEMPLATES = [
26
+ {
27
+ "BACKEND": "django.template.backends.django.DjangoTemplates",
28
+ "DIRS": [],
29
+ "APP_DIRS": True,
30
+ "OPTIONS": {
31
+ "builtins": [
32
+ "profiling_explorer.templatetags.profiling_explorer_tags",
33
+ "django.contrib.humanize.templatetags.humanize",
34
+ ],
35
+ },
36
+ }
37
+ ]
@@ -0,0 +1,84 @@
1
+ async function fetchDoc(url, options) {
2
+ const response = await fetch(url, options);
3
+ const html = await response.text();
4
+ return new DOMParser().parseFromString(html, 'text/html');
5
+ }
6
+
7
+ // Filter box
8
+ const searchInput = document.getElementById('pe-search');
9
+ let searchTimeout = null;
10
+ let searchAbort = null;
11
+
12
+ searchInput.addEventListener('input', () => {
13
+ clearTimeout(searchTimeout);
14
+ searchTimeout = setTimeout(async () => {
15
+ const q = searchInput.value.trim();
16
+ const url = new URL(window.location.href);
17
+ if (q) {
18
+ url.searchParams.set('q', q);
19
+ } else {
20
+ url.searchParams.delete('q');
21
+ }
22
+ history.replaceState(null, '', url);
23
+
24
+ searchAbort?.abort();
25
+ searchAbort = new AbortController();
26
+ try {
27
+ const doc = await fetchDoc(url, { signal: searchAbort.signal });
28
+ document.querySelector('main').replaceWith(doc.querySelector('main'));
29
+ } catch (e) {
30
+ if (e.name !== 'AbortError') throw e;
31
+ }
32
+ }, 300);
33
+ });
34
+
35
+ // Copy buttons
36
+ document.addEventListener('click', (e) => {
37
+ const btn = e.target.closest('button.copy-btn');
38
+ if (!btn) return;
39
+
40
+ const text = btn.dataset.copy;
41
+ navigator.clipboard.writeText(text).then(() => {
42
+ btn.classList.add('copied');
43
+ setTimeout(() => btn.classList.remove('copied'), 1500);
44
+ });
45
+ });
46
+
47
+
48
+ // Pagination
49
+ class PePaginationMarker extends HTMLElement {
50
+ connectedCallback() {
51
+ this._observer = new IntersectionObserver(
52
+ (entries) => {
53
+ if (entries[0].isIntersecting) {
54
+ this._observer.disconnect();
55
+ this._load();
56
+ }
57
+ },
58
+ { root: document.querySelector('main'), rootMargin: '200px' }
59
+ );
60
+ this._observer.observe(this);
61
+ }
62
+
63
+ disconnectedCallback() {
64
+ this._observer?.disconnect();
65
+ }
66
+
67
+ async _load() {
68
+ const doc = await fetchDoc(this.dataset.url);
69
+
70
+ const tbody = document.querySelector('tbody');
71
+ for (const row of doc.querySelectorAll('tbody tr')) {
72
+ tbody.appendChild(document.adoptNode(row));
73
+ }
74
+
75
+ const nextMarker = doc.querySelector('pe-pagination-marker');
76
+ if (nextMarker) {
77
+ this.replaceWith(document.adoptNode(nextMarker));
78
+ } else {
79
+ this.remove();
80
+ }
81
+ }
82
+ }
83
+
84
+ customElements.define('pe-pagination-marker', PePaginationMarker);