How bahaarawass/wordcount-parallel works
This is a Python teaching demo for whole-word counting and parallel-computing experiments. The main workflow reads UTF-8 lines, counts assigned ranges using threads, combines partial counts, and reports a total and optional trace. Separate commands generate reproducible input, compare threaded and process-based timings, and demonstrate a controlled lost update. The graph reflects the sampled implementation and README; the experiment’s plotting and artifact outputs are documented, while no distributed runtime is shown.
Main entry points: cli.py Count CLI · experiment.py Benchmark runner · core.py Thread counting · generate.py Input generator
Components 13
Word counting
- Count CLI
src/wordcount/cli.py - Token scanner
src/wordcount/core.py - Thread counting
src/wordcount/core.py - Process counting
src/wordcount/core.py
Experiments
- Input generator
src/wordcount/generate.py - Benchmark runner
src/wordcount/experiment.py
Teaching demos
- Race demo
src/wordcount/race.py
Other components
- CLI user
- UTF-8 input
- Count output
- Generated input
- Benchmark artifacts
- Race output
Connections 20
- CLI user → Count CLI: runs
README.md - UTF-8 input → Count CLI: provides file
src/wordcount/cli.py - Count CLI → Token scanner: loads lines
src/wordcount/cli.py - Count CLI → Thread counting: dispatches threads
src/wordcount/cli.py - Count CLI → Process counting: dispatches processes
src/wordcount/cli.py - Thread counting → Token scanner: scans ranges
src/wordcount/core.py - Process counting → Token scanner: submits scans
src/wordcount/core.py - Thread counting → Count CLI: returns counts
src/wordcount/cli.py - Process counting → Count CLI: returns counts
src/wordcount/cli.py - Count CLI → Count output: prints total
src/wordcount/cli.py - CLI user → Input generator: runs
README.md - Input generator → Generated input: writes input
src/wordcount/generate.py - CLI user → Benchmark runner: runs
README.md - UTF-8 input → Benchmark runner: provides file
src/wordcount/experiment.py - Benchmark runner → Token scanner: loads lines
src/wordcount/experiment.py - Benchmark runner → Thread counting: benchmarks threads
src/wordcount/experiment.py - Benchmark runner → Process counting: benchmarks processes
src/wordcount/experiment.py - Benchmark runner → Benchmark artifacts: writes reports
src/wordcount/experiment.py - CLI user → Race demo: runs
README.md - Race demo → Race output: prints comparison
src/wordcount/race.py