Skip to content

Commit aedb4b1

Browse files
authored
Merge pull request #146 from pythonspeed/140-svg-with-just-rust
Generage SVG with just Rust, and make monospace more reliably
2 parents 69e98ef + 61760d4 commit aedb4b1

18 files changed

Lines changed: 353 additions & 177 deletions

.changelog/140.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Number of allocations in the profiling results are now limited to 10,000. If there are more than this, they are all quite tiny, so probably less informative, and including massive number of tiny allocations makes report generation (and report display) extremely resource intensive.

.changelog/143.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Try to ensure monospace font is used for reports.

Cargo.lock

Lines changed: 137 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,8 @@ test:
2525

2626
.PHONY: test-rust
2727
test-rust:
28-
env RUST_BACKTRACE=1 cargo test
28+
cd memapi && env RUST_BACKTRACE=1 cargo test --no-default-features
29+
cd filpreload && env RUST_BACKTRACE=1 cargo test --no-default-features
2930

3031
.PHONY: test-python
3132
test-python: build
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"D1mr": 4672497,
3-
"D1mw": 2848442,
4-
"DLmr": 1538198,
5-
"DLmw": 1838844,
6-
"Dr": 250089588,
7-
"Dw": 102656740,
8-
"I1mr": 4289774,
9-
"ILmr": 15889,
10-
"Ir": 955546002,
11-
"Overall": 1457323112
2+
"D1mr": 3665605,
3+
"D1mw": 2723841,
4+
"DLmr": 1439693,
5+
"DLmw": 1753964,
6+
"Dr": 221171589,
7+
"Dw": 90534144,
8+
"I1mr": 3979900,
9+
"ILmr": 14247,
10+
"Ir": 855002519,
11+
"Overall": 1304422756
1212
}
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"D1mr": 2886684,
3-
"D1mw": 550189,
4-
"DLmr": 127427,
5-
"DLmw": 125319,
6-
"Dr": 106205156,
7-
"Dw": 44576260,
8-
"I1mr": 2451355,
9-
"ILmr": 10001,
10-
"Ir": 364824726,
11-
"Overall": 547041464
2+
"D1mr": 1890512,
3+
"D1mw": 411404,
4+
"DLmr": 68277,
5+
"DLmw": 85971,
6+
"Dr": 77312316,
7+
"Dw": 32347615,
8+
"I1mr": 1642608,
9+
"ILmr": 8418,
10+
"Ir": 264077600,
11+
"Overall": 394395607
1212
}

benchmarks/results/pystone.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
{
2-
"D1mr": 7100997,
3-
"D1mw": 1292155,
4-
"DLmr": 96260,
5-
"DLmw": 101140,
6-
"Dr": 384212115,
7-
"Dw": 157757614,
8-
"I1mr": 10109668,
9-
"ILmr": 9792,
10-
"Ir": 1241047480,
11-
"Overall": 1863244249
2+
"D1mr": 2035945,
3+
"D1mw": 817906,
4+
"DLmr": 32069,
5+
"DLmw": 61536,
6+
"Dr": 354442923,
7+
"Dw": 145400642,
8+
"I1mr": 10056133,
9+
"ILmr": 8203,
10+
"Ir": 1135020106,
11+
"Overall": 1689557847
1212
}

benchmarks/results/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.15.1.dev8+gb3d53c1.d20210223
1+
0.17.1.dev8+g76bf95d.d20210318

filprofiler/_report.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@
66
"""
77

88
from datetime import datetime
9-
import linecache
109
import os
1110
import shlex
12-
import re
1311
import sys
14-
from xml.sax.saxutils import escape
1512
from urllib.parse import quote_plus as url_quote
16-
import html
1713
from . import __version__
1814

19-
LINE_REFERENCE = re.compile(r"\<title\>TB@@([^:]+):(\d+)@@TB")
20-
2115
DEBUGGING_INFO = url_quote(
2216
f"""\
2317
## Version information
@@ -27,47 +21,8 @@
2721
)
2822

2923

30-
def replace_code_references(string: str) -> str:
31-
"""
32-
Replace occurrences of TB@@file.py:123@@TB with the line of code at that
33-
location, XML quoted and slightly indented.
34-
"""
35-
36-
def replace_with_code(match):
37-
filename, line = match.group(1, 2)
38-
filename = html.unescape(filename)
39-
line = int(line)
40-
return "<title>&#160;&#160;&#160;&#160;" + escape(
41-
linecache.getline(filename, line).strip()
42-
)
43-
44-
return re.sub(LINE_REFERENCE, replace_with_code, string)
45-
46-
47-
def update_svg(svg_path: str):
48-
"""Fix up the SVGs.
49-
50-
1. Add an appropriate subtitle.
51-
2. Add source code lines.
52-
"""
53-
with open(svg_path) as f:
54-
data = f.read().replace(
55-
"SUBTITLE-HERE",
56-
"""Made with the Fil memory profiler. <a href="https://pythonspeed.com/products/filmemoryprofiler/" style="text-decoration: underline;" target="_parent">Try it on your code!</a>""",
57-
)
58-
data = replace_code_references(data)
59-
with open(svg_path, "w") as f:
60-
f.write(data)
61-
62-
6324
def render_report(output_path: str, now: datetime) -> str:
6425
"""Write out the HTML index and improve the SVGs."""
65-
for svg_path in [
66-
os.path.join(output_path, "peak-memory.svg"),
67-
os.path.join(output_path, "peak-memory-reversed.svg"),
68-
]:
69-
update_svg(svg_path)
70-
7126
index_path = os.path.join(output_path, "index.html")
7227
with open(index_path, "w") as index:
7328
index.write(

filprofiler/_testing.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ def get_allocations(
3030
result[calls] = size_kb
3131
continue
3232
for call in calls.split(";"):
33-
if call.startswith("TB@@"):
34-
continue
3533
part1, func_name = call.rsplit(" ", 1)
3634
assert func_name[0] == "("
3735
assert func_name[-1] == ")"

0 commit comments

Comments
 (0)