A comprehensive benchmarking suite that compares file I/O performance across Python, Go, and Kotlin implementations. This project provides detailed performance analysis with statistical rigor and beautiful visualizations.
- π Multi-language benchmarking: Tests Python, Go, and Kotlin I/O performance
- π Multiple file sizes: Tests with 1MB, 10MB, 50MB, and 100MB files
- π Statistical analysis: Multiple iterations with mean, median, min, max, and standard deviation
- π Visual comparisons: Generates performance charts and graphs
- β‘ Throughput metrics: Measures MB/s for read and write operations
- π€ Automated execution: Single command runs all benchmarks
- π§ Cross-platform: Works on macOS, Linux, and Windows
βββ benchmark_runner.py # π― Main benchmark orchestrator
βββ quick_test.py # π§ͺ Quick implementation tester
βββ test_setup.py # βοΈ Setup verification script
βββ python/
β βββ io_benchmark.py # π Python I/O implementation
β βββ io_test.py # π Python test runner
βββ golang/
β βββ main.go # πΉ Go I/O implementation
β βββ go.mod # πΉ Go module definition
βββ kotlin/
β βββ app/
β βββ src/main/kotlin/org/example/
β βββ App.kt # π― Kotlin I/O implementation
βββ data/ # π Test files (auto-generated)
βββ results/ # π Benchmark results (auto-generated)
βββ Makefile # π¨ Build and run commands
βββ requirements.txt # π¦ Python dependencies
βββ .gitignore # π« Git ignore rules
- π Python 3.7+
- πΉ Go 1.19+
- β Java 11+ (for Kotlin)
- π¨ Make (build automation)
-
Clone the repository
git clone https://github.com/yourusername/io-performance-comparison.git cd io-performance-comparison
-
Install dependencies (creates Python virtual environment automatically)
make install-deps
π‘ Note: On macOS/Linux, this automatically creates a Python virtual environment to avoid conflicts with system Python packages.
Run the complete benchmark suite:
make benchmark
Test individual implementations:
make test-individual
Quick verification test:
python3 quick_test.py
Run specific language tests:
make run-python # π Python only
make run-go # πΉ Go only
make run-kotlin # Kotlin only
- Write Test: Copy a test file using 8KB buffer chunks
- Read Test: Read the copied file using 8KB buffer chunks
- 1 MB
- 10 MB
- 50 MB
- 100 MB
- Execution Time: Time taken for read/write operations
- Throughput: MB/s for each operation
- Statistical Analysis: Mean, median, min, max, standard deviation
- Relative Performance: Performance ratios compared to Go baseline
Here's what you can expect from the benchmark results:
Language | File Size | Read (MB/s) | Write (MB/s) |
---|---|---|---|
Go | 100MB | 3,856 | 815 |
Kotlin | 100MB | 4,054 | 802 |
Python | 100MB | 4,054 | 805 |
Results may vary based on hardware and system configuration
After running benchmarks, check the results/
directory:
- π
benchmark_results.json
: Raw benchmark data with all iterations - π
benchmark_summary.csv
: Tabulated results with statistics - π
io_performance_comparison.png
: Performance visualization charts
- Uses built-in
open()
with binary mode - 8KB buffer size for chunked I/O
- Context managers for proper file handling
- JSON output for benchmark results
- Uses
os.Open()
andos.Create()
- 8KB byte slice buffer
- Proper error handling and resource cleanup
- Structured JSON output with custom types
- Uses
FileInputStream
/FileOutputStream
- 8KB ByteArray buffer
- Automatic resource management with
use{}
- Gson for JSON serialization
Typical performance characteristics:
- Go: Generally fastest, especially for large files
- Kotlin: Close to Go performance, benefits from JVM optimizations
- Python: Slower for pure I/O, but difference narrows with larger files
Results vary based on:
- Hardware (SSD vs HDD, CPU, RAM)
- Operating system
- File system type
- System load
Edit benchmark_runner.py
:
self.test_file_sizes = [1, 10, 50, 100] # File sizes in MB
self.iterations = 3 # Number of test runs
Update buffer size in each implementation:
- Python:
chunk = f_in.read(8192)
- Go:
buf := make([]byte, 8192)
- Kotlin:
val buffer = ByteArray(8192)
- Missing dependencies: Run
make install-deps
- Permission errors: Ensure write access to project directory
- Out of disk space: Large test files require sufficient free space
- Java/Kotlin build errors: Verify Java 11+ is installed
Remove generated files:
make clean
Remove everything including virtual environment:
make clean-all
We welcome contributions! Here's how you can help:
- π΄ Fork the repository
- πΏ Create a feature branch (
git checkout -b feature/amazing-feature
) - β¨ Add your improvements
- New language implementations
- Performance optimizations
- Better visualizations
- Bug fixes
- π Commit your changes (
git commit -m 'Add amazing feature'
) - π Push to the branch (
git push origin feature/amazing-feature
) - π Submit a pull request
- π¦ Rust implementation
- π· C# implementation
- β Java implementation
- π More visualization options
- π§ Different I/O patterns (async, memory-mapped, etc.)
- π§ͺ Additional test scenarios
MIT License - see LICENSE file for details.
- Thanks to all contributors who help improve this benchmark suite
- Inspired by the need for fair, comprehensive I/O performance comparisons
- Built with β€οΈ for the developer community
β If this project helped you, please give it a star!