Skip to content

Commit bc24fee

Browse files
kylehowellsclaude
andcommitted
Code review cleanup and formatting
- Extract duplicate fragment context handling to tokenizerOpts() helper - Remove unused SELECT_SCOPE_ELEMENTS constant - Update HTMLStream documentation to accurately describe behavior - Fix compare.py benchmark script (correct product capitalization) - Apply swift-format across codebase - Add code review notes documenting findings No performance regression - all tests pass. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 0d8b61e commit bc24fee

27 files changed

+16960
-17100
lines changed

Benchmarks/BENCHMARK_RESULTS.md

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
# Cross-Implementation Benchmark Results
22

3-
**Generated:** 2025-12-17 18:39:43
3+
**Generated:** 2025-12-18 08:25:27
44

55
## Repository Versions
66

77
| Project | Branch | Commit | Date |
88
|---------|--------|--------|------|
9-
| swift-justhtml | turbo | `76fee4992b72` | 2025-12-17 |
9+
| swift-justhtml | master | `0d8b61ecd58e` | 2025-12-18 |
1010
| justhtml (Python) | main | `63c29b26be64` | 2025-12-16 |
1111
| justjshtml (JavaScript) | main | `e29dbd3166e9` | 2025-12-16 |
1212

@@ -17,6 +17,7 @@ All implementations produce **identical output** for all test files.
1717
| File | Status |
1818
|------|--------|
1919
| hackernews.html | ✅ OK |
20+
| synthetic.html | ✅ OK |
2021
| wikipedia_countries.html | ✅ OK |
2122
| wikipedia_html.html | ✅ OK |
2223
| wikipedia_swift.html | ✅ OK |
@@ -26,29 +27,31 @@ All implementations produce **identical output** for all test files.
2627

2728
| File | Size | Swift | Python | JavaScript | Swift vs Python | Swift vs JS |
2829
|------|------|-------|--------|------------|-----------------|-------------|
29-
| hackernews.html | 34 KB | 2.09 ms | 7.65 ms | 1.59 ms | 3.67x faster | 1.31x slower |
30-
| wikipedia_countries.html | 360 KB | 14.61 ms | 62.27 ms | 14.60 ms | 4.26x faster | 1.00x slower |
31-
| wikipedia_html.html | 472 KB | 18.81 ms | 79.89 ms | 19.65 ms | 4.25x faster | 1.04x faster |
32-
| wikipedia_swift.html | 411 KB | 16.96 ms | 67.02 ms | 16.96 ms | 3.95x faster | 1.00x faster |
33-
| wikipedia_ww2.html | 1204 KB | 44.02 ms | 181.64 ms | 46.39 ms | 4.13x faster | 1.05x faster |
34-
| **TOTAL** | | **96 ms** | **398 ms** | **99 ms** | **4.13x faster** | **1.03x faster** |
30+
| hackernews.html | 34 KB | 2.12 ms | 7.79 ms | 1.71 ms | 3.68x faster | 1.24x slower |
31+
| synthetic.html | 20498 KB | 1221.96 ms | 3595.00 ms | 933.79 ms | 2.94x faster | 1.31x slower |
32+
| wikipedia_countries.html | 360 KB | 14.27 ms | 90.08 ms | 14.99 ms | 6.31x faster | 1.05x faster |
33+
| wikipedia_html.html | 472 KB | 18.89 ms | 104.40 ms | 20.56 ms | 5.53x faster | 1.09x faster |
34+
| wikipedia_swift.html | 411 KB | 16.98 ms | 132.85 ms | 16.54 ms | 7.82x faster | 1.03x slower |
35+
| wikipedia_ww2.html | 1204 KB | 44.00 ms | 238.61 ms | 47.92 ms | 5.42x faster | 1.09x faster |
36+
| **TOTAL** | | **1318 ms** | **4169 ms** | **1036 ms** | **3.16x faster** | **1.27x slower** |
3537

3638
## Summary
3739

38-
- **Swift** total parse time: 96 ms
39-
- **Python** total parse time: 398 ms
40-
- **JavaScript** total parse time: 99 ms
40+
- **Swift** total parse time: 1318 ms
41+
- **Python** total parse time: 4169 ms
42+
- **JavaScript** total parse time: 1036 ms
4143

42-
**Swift** is the fastest implementation.
44+
**JavaScript** is the fastest implementation (V8 JIT optimization).
4345

44-
Swift is **4.1x faster** than Python.
45-
JavaScript is **1.0x faster** than Swift.
46+
Swift is **3.2x faster** than Python.
47+
JavaScript is **1.3x faster** than Swift.
4648

4749
## Test Files
4850

4951
| File | Source | Size |
5052
|------|--------|------|
5153
| hackernews.html | Hacker News | 34,478 bytes |
54+
| synthetic.html | Generated (stress test) | 20,990,426 bytes |
5255
| wikipedia_countries.html | Wikipedia | 369,101 bytes |
5356
| wikipedia_html.html | Wikipedia | 483,786 bytes |
5457
| wikipedia_swift.html | Wikipedia | 420,395 bytes |

Benchmarks/compare.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def run_swift_benchmark():
8383

8484
# Build release version
8585
result = subprocess.run(
86-
["swift", "build", "-c", "release", "--product", "benchmark"],
86+
["swift", "build", "-c", "release", "--product", "Benchmark"],
8787
cwd=SWIFT_PROJECT_ROOT,
8888
capture_output=True,
8989
text=True
@@ -94,7 +94,7 @@ def run_swift_benchmark():
9494

9595
# Run benchmark
9696
result = subprocess.run(
97-
["swift", "run", "-c", "release", "benchmark"],
97+
["swift", "run", "-c", "release", "Benchmark"],
9898
cwd=SWIFT_PROJECT_ROOT,
9999
capture_output=True,
100100
text=True

0 commit comments

Comments
 (0)