turboapi 0.3.21__tar.gz → 0.3.24__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 (105) hide show
  1. {turboapi-0.3.21 → turboapi-0.3.24}/AGENTS.md +5 -3
  2. {turboapi-0.3.21 → turboapi-0.3.24}/Cargo.lock +1 -1
  3. {turboapi-0.3.21 → turboapi-0.3.24}/Cargo.toml +1 -1
  4. {turboapi-0.3.21 → turboapi-0.3.24}/PKG-INFO +1 -1
  5. {turboapi-0.3.21 → turboapi-0.3.24}/README.md +22 -22
  6. {turboapi-0.3.21 → turboapi-0.3.24}/pyproject.toml +1 -1
  7. {turboapi-0.3.21 → turboapi-0.3.24}/python/pyproject.toml +1 -1
  8. {turboapi-0.3.21 → turboapi-0.3.24}/src/server.rs +18 -5
  9. turboapi-0.3.24/tests/async_benchmark.sh +64 -0
  10. turboapi-0.3.24/tests/quick_benchmark.sh +63 -0
  11. turboapi-0.3.24/tests/test_async_benchmark.py +55 -0
  12. {turboapi-0.3.21 → turboapi-0.3.24}/tests/test_v0_3_20_server.py +6 -5
  13. {turboapi-0.3.21 → turboapi-0.3.24}/.github/scripts/check_performance_regression.py +0 -0
  14. {turboapi-0.3.21 → turboapi-0.3.24}/.github/scripts/compare_benchmarks.py +0 -0
  15. {turboapi-0.3.21 → turboapi-0.3.24}/.github/workflows/README.md +0 -0
  16. {turboapi-0.3.21 → turboapi-0.3.24}/.github/workflows/benchmark.yml +0 -0
  17. {turboapi-0.3.21 → turboapi-0.3.24}/.github/workflows/build-and-release.yml +0 -0
  18. {turboapi-0.3.21 → turboapi-0.3.24}/.github/workflows/build-wheels.yml +0 -0
  19. {turboapi-0.3.21 → turboapi-0.3.24}/.github/workflows/ci.yml +0 -0
  20. {turboapi-0.3.21 → turboapi-0.3.24}/.github/workflows/release.yml +0 -0
  21. {turboapi-0.3.21 → turboapi-0.3.24}/.gitignore +0 -0
  22. {turboapi-0.3.21 → turboapi-0.3.24}/CHANGELOG.md +0 -0
  23. {turboapi-0.3.21 → turboapi-0.3.24}/FASTAPI_COMPATIBILITY.md +0 -0
  24. {turboapi-0.3.21 → turboapi-0.3.24}/FASTAPI_FIXES_SUMMARY.md +0 -0
  25. {turboapi-0.3.21 → turboapi-0.3.24}/LICENSE +0 -0
  26. {turboapi-0.3.21 → turboapi-0.3.24}/PYTHON_313_FREE_THREADING_SETUP.md +0 -0
  27. {turboapi-0.3.21 → turboapi-0.3.24}/PYTHON_SETUP_COMPLETE.md +0 -0
  28. {turboapi-0.3.21 → turboapi-0.3.24}/RELEASE_NOTES_v0.3.1.md +0 -0
  29. {turboapi-0.3.21 → turboapi-0.3.24}/RELEASE_NOTES_v0.3.13.md +0 -0
  30. {turboapi-0.3.21 → turboapi-0.3.24}/WINDOWS_FIX_SUMMARY.md +0 -0
  31. {turboapi-0.3.21 → turboapi-0.3.24}/adaptive_rate_test.py +0 -0
  32. {turboapi-0.3.21 → turboapi-0.3.24}/benches/performance_bench.rs +0 -0
  33. {turboapi-0.3.21 → turboapi-0.3.24}/benchmark_comparison.png +0 -0
  34. {turboapi-0.3.21 → turboapi-0.3.24}/benchmark_graphs/turbo_vs_fastapi_performance_20250929_025531.png +0 -0
  35. {turboapi-0.3.21 → turboapi-0.3.24}/benchmark_output.txt +0 -0
  36. {turboapi-0.3.21 → turboapi-0.3.24}/claude.md +0 -0
  37. {turboapi-0.3.21 → turboapi-0.3.24}/delete/blog/adr_python_handler_integration.md +0 -0
  38. {turboapi-0.3.21 → turboapi-0.3.24}/delete/blog/phase_1.md +0 -0
  39. {turboapi-0.3.21 → turboapi-0.3.24}/delete/blog/phase_2.md +0 -0
  40. {turboapi-0.3.21 → turboapi-0.3.24}/delete/blog/phase_3.md +0 -0
  41. {turboapi-0.3.21 → turboapi-0.3.24}/delete/blog/phase_4.md +0 -0
  42. {turboapi-0.3.21 → turboapi-0.3.24}/delete/blog/phase_5.md +0 -0
  43. {turboapi-0.3.21 → turboapi-0.3.24}/delete/twitterpost.md +0 -0
  44. {turboapi-0.3.21 → turboapi-0.3.24}/install_benchmark_deps.py +0 -0
  45. {turboapi-0.3.21 → turboapi-0.3.24}/mini-notes/001-foundation.md +0 -0
  46. {turboapi-0.3.21 → turboapi-0.3.24}/mini-notes/002-routing-breakthrough.md +0 -0
  47. {turboapi-0.3.21 → turboapi-0.3.24}/mini-notes/003-production-ready.md +0 -0
  48. {turboapi-0.3.21 → turboapi-0.3.24}/mini-notes/004-zero-copy-revolution.md +0 -0
  49. {turboapi-0.3.21 → turboapi-0.3.24}/mini-notes/005-middleware-mastery.md +0 -0
  50. {turboapi-0.3.21 → turboapi-0.3.24}/mini-notes/006-python-handler-breakthrough.md +0 -0
  51. {turboapi-0.3.21 → turboapi-0.3.24}/mini-notes/README.md +0 -0
  52. {turboapi-0.3.21 → turboapi-0.3.24}/mini-notes/lessons-learned.md +0 -0
  53. {turboapi-0.3.21 → turboapi-0.3.24}/python/MANIFEST.in +0 -0
  54. {turboapi-0.3.21 → turboapi-0.3.24}/python/setup.py +0 -0
  55. {turboapi-0.3.21 → turboapi-0.3.24}/python/turboapi/__init__.py +0 -0
  56. {turboapi-0.3.21 → turboapi-0.3.24}/python/turboapi/decorators.py +0 -0
  57. {turboapi-0.3.21 → turboapi-0.3.24}/python/turboapi/main_app.py +0 -0
  58. {turboapi-0.3.21 → turboapi-0.3.24}/python/turboapi/middleware.py +0 -0
  59. {turboapi-0.3.21 → turboapi-0.3.24}/python/turboapi/models.py +0 -0
  60. {turboapi-0.3.21 → turboapi-0.3.24}/python/turboapi/request_handler.py +0 -0
  61. {turboapi-0.3.21 → turboapi-0.3.24}/python/turboapi/routing.py +0 -0
  62. {turboapi-0.3.21 → turboapi-0.3.24}/python/turboapi/rust_integration.py +0 -0
  63. {turboapi-0.3.21 → turboapi-0.3.24}/python/turboapi/server_integration.py +0 -0
  64. {turboapi-0.3.21 → turboapi-0.3.24}/python/turboapi/version_check.py +0 -0
  65. {turboapi-0.3.21 → turboapi-0.3.24}/setup_python313t.sh +0 -0
  66. {turboapi-0.3.21 → turboapi-0.3.24}/src/http2.rs +0 -0
  67. {turboapi-0.3.21 → turboapi-0.3.24}/src/lib.rs +0 -0
  68. {turboapi-0.3.21 → turboapi-0.3.24}/src/micro_bench.rs +0 -0
  69. {turboapi-0.3.21 → turboapi-0.3.24}/src/middleware.rs +0 -0
  70. {turboapi-0.3.21 → turboapi-0.3.24}/src/request.rs +0 -0
  71. {turboapi-0.3.21 → turboapi-0.3.24}/src/response.rs +0 -0
  72. {turboapi-0.3.21 → turboapi-0.3.24}/src/router.rs +0 -0
  73. {turboapi-0.3.21 → turboapi-0.3.24}/src/threadpool.rs +0 -0
  74. {turboapi-0.3.21 → turboapi-0.3.24}/src/validation.rs +0 -0
  75. {turboapi-0.3.21 → turboapi-0.3.24}/src/websocket.rs +0 -0
  76. {turboapi-0.3.21 → turboapi-0.3.24}/src/zerocopy.rs +0 -0
  77. {turboapi-0.3.21 → turboapi-0.3.24}/test_no_rate_limit.py +0 -0
  78. {turboapi-0.3.21 → turboapi-0.3.24}/test_rate_limiting.py +0 -0
  79. {turboapi-0.3.21 → turboapi-0.3.24}/test_zerocopy.py +0 -0
  80. {turboapi-0.3.21 → turboapi-0.3.24}/tests/README.md +0 -0
  81. {turboapi-0.3.21 → turboapi-0.3.24}/tests/benchmark_comparison.py +0 -0
  82. {turboapi-0.3.21 → turboapi-0.3.24}/tests/comparison_before_after.py +0 -0
  83. {turboapi-0.3.21 → turboapi-0.3.24}/tests/fastapi_equivalent.py +0 -0
  84. {turboapi-0.3.21 → turboapi-0.3.24}/tests/fastapi_v0_3_20_equivalent.py +0 -0
  85. {turboapi-0.3.21 → turboapi-0.3.24}/tests/quick_body_test.py +0 -0
  86. {turboapi-0.3.21 → turboapi-0.3.24}/tests/quick_test.py +0 -0
  87. {turboapi-0.3.21 → turboapi-0.3.24}/tests/run_v0_3_20_benchmark.py +0 -0
  88. {turboapi-0.3.21 → turboapi-0.3.24}/tests/test.py +0 -0
  89. {turboapi-0.3.21 → turboapi-0.3.24}/tests/test_fastapi_compatibility.py +0 -0
  90. {turboapi-0.3.21 → turboapi-0.3.24}/tests/test_v0_3_20_fixes.py +0 -0
  91. {turboapi-0.3.21 → turboapi-0.3.24}/tests/test_v0_3_21_async.py +0 -0
  92. {turboapi-0.3.21 → turboapi-0.3.24}/tests/wrk_benchmark.py +0 -0
  93. {turboapi-0.3.21 → turboapi-0.3.24}/tests/wrk_comparison.py +0 -0
  94. {turboapi-0.3.21 → turboapi-0.3.24}/turbo_vs_fastapi_benchmark_20250929_025526.json +0 -0
  95. {turboapi-0.3.21 → turboapi-0.3.24}/turboapi/__init__.py +0 -0
  96. {turboapi-0.3.21 → turboapi-0.3.24}/turboapi/decorators.py +0 -0
  97. {turboapi-0.3.21 → turboapi-0.3.24}/turboapi/main_app.py +0 -0
  98. {turboapi-0.3.21 → turboapi-0.3.24}/turboapi/middleware.py +0 -0
  99. {turboapi-0.3.21 → turboapi-0.3.24}/turboapi/models.py +0 -0
  100. {turboapi-0.3.21 → turboapi-0.3.24}/turboapi/request_handler.py +0 -0
  101. {turboapi-0.3.21 → turboapi-0.3.24}/turboapi/routing.py +0 -0
  102. {turboapi-0.3.21 → turboapi-0.3.24}/turboapi/rust_integration.py +0 -0
  103. {turboapi-0.3.21 → turboapi-0.3.24}/turboapi/server_integration.py +0 -0
  104. {turboapi-0.3.21 → turboapi-0.3.24}/turboapi/version_check.py +0 -0
  105. {turboapi-0.3.21 → turboapi-0.3.24}/wrk_rate_limit_test.py +0 -0
@@ -1,15 +1,17 @@
1
- # TurboAPI v0.3.0+ - AI Agent Guide 🤖
1
+ # TurboAPI v0.3.23 - AI Agent Guide 🤖
2
2
 
3
3
  **For AI assistants, code generation tools, and automated development systems**
4
4
 
5
5
  ## 🎯 **What TurboAPI Is**
6
6
 
7
- TurboAPI is a **FastAPI-compatible** Python web framework that delivers **5-10x better performance** through:
7
+ TurboAPI is a **FastAPI-compatible** Python web framework that delivers **9-10x better performance** through:
8
8
  - **Rust-powered HTTP core** (zero Python overhead)
9
- - **Python 3.13 free-threading** support (true parallelism)
9
+ - **Python 3.13 free-threading** with `Python::attach()` (TRUE parallel execution)
10
+ - **pyo3-async-runtimes** integration (native tokio async support)
10
11
  - **Zero-copy optimizations** and intelligent caching
11
12
  - **100% FastAPI syntax compatibility** with automatic body parsing
12
13
  - **Satya validation** (faster than Pydantic)
14
+ - **72,000+ req/s** in production benchmarks
13
15
 
14
16
  ## 🚀 **For AI Agents: Key Facts**
15
17
 
@@ -1439,7 +1439,7 @@ dependencies = [
1439
1439
 
1440
1440
  [[package]]
1441
1441
  name = "turbonet"
1442
- version = "0.3.21"
1442
+ version = "0.3.24"
1443
1443
  dependencies = [
1444
1444
  "anyhow",
1445
1445
  "bytes",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "turbonet"
3
- version = "0.3.21"
3
+ version = "0.3.24"
4
4
  edition = "2021"
5
5
  authors = ["Rach Pradhan <rach@turboapi.dev>"]
6
6
  description = "High-performance Python web framework core - Rust-powered HTTP server with Python 3.13 free-threading support"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: turboapi
3
- Version: 0.3.21
3
+ Version: 0.3.24
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -1,12 +1,13 @@
1
1
  # TurboAPI 🚀
2
2
 
3
- **The Python web framework that gives you FastAPI's beloved developer experience with 5-10x the performance.**
3
+ **The Python web framework that gives you FastAPI's beloved developer experience with 9-10x the performance.**
4
4
 
5
- Built with Rust for revolutionary speed, designed with Python for developer happiness.
5
+ Built with Rust for revolutionary speed, designed with Python for developer happiness. **First framework to leverage Python 3.13 free-threading for true parallel request handling!**
6
6
 
7
7
  > **⚡ Try it in 30 seconds:** `python live_performance_showcase.py` → Visit `http://127.0.0.1:8080`
8
- > **🔥 See the difference:** Same FastAPI syntax, 5-10x faster performance!
9
- > **🎯 Zero migration effort:** Change 1 import line, keep all your existing code
8
+ > **🔥 72,000+ requests/sec:** 9-10x faster than FastAPI in real benchmarks!
9
+ > **🎯 Zero migration effort:** Change 1 import line, keep all your existing code
10
+ > **🧵 Python 3.13 Free-Threading:** TRUE parallel Python execution - no GIL!
10
11
 
11
12
  ## 🎨 **100% FastAPI-Compatible Developer Experience**
12
13
 
@@ -46,32 +47,31 @@ app.run(host="127.0.0.1", port=8000)
46
47
 
47
48
  ## 🚀 **Revolutionary Performance**
48
49
 
49
- ### **Why TurboAPI is 5-10x Faster**
50
+ ### **Why TurboAPI is 9-10x Faster**
50
51
  - **🦀 Rust-Powered HTTP Core**: Zero Python overhead for request handling
51
52
  - **⚡ Zero Middleware Overhead**: Rust-native middleware pipeline
52
- - **🧵 Free-Threading Ready**: True parallelism for Python 3.13+
53
+ - **🧵 Python 3.13 Free-Threading**: TRUE parallel Python execution with `Python::attach()`
53
54
  - **💾 Zero-Copy Optimizations**: Direct memory access, no Python copying
54
- - **🔄 Intelligent Caching**: Response caching with TTL optimization
55
+ - **🔄 pyo3-async-runtimes**: Native tokio integration for async handlers
56
+ - **🎯 Multi-threaded**: 3x CPU cores worker threads for maximum throughput
55
57
 
56
- ### **Benchmark Results vs FastAPI** (wrk load testing)
57
-
58
- ![Benchmark Comparison](benchmark_comparison.png)
58
+ ### **Benchmark Results vs FastAPI** (v0.3.23 - wrk, 4 threads, 100 connections)
59
59
 
60
60
  ```
61
- 🎯 Light Load (50 connections):
62
- Root Endpoint: 42,803 req/s (TurboAPI) vs 8,078 req/s (FastAPI) = 5.3x faster
63
- Simple Endpoint: 43,375 req/s (TurboAPI) vs 8,536 req/s (FastAPI) = 5.1x faster
64
- JSON Endpoint: 41,696 req/s (TurboAPI) vs 3,208 req/s (FastAPI) = 13.0x faster
61
+ 🎯 TurboAPI v0.3.23 (Python 3.13 Free-Threading):
62
+ Simple GET: 72,903 req/s | Latency: ~1.4ms
63
+ Parameterized: 71,690 req/s | Latency: ~1.4ms
64
+ Async Handlers: 13,417 req/s | Latency: ~7.5ms
65
65
 
66
- 🎯 Medium Load (200 connections):
67
- Root Endpoint: 42,874 req/s (TurboAPI) vs 8,220 req/s (FastAPI) = 5.2x faster
68
- Simple Endpoint: 43,592 req/s (TurboAPI) vs 8,542 req/s (FastAPI) = 5.1x faster
69
- JSON Endpoint: 41,822 req/s (TurboAPI) vs 3,190 req/s (FastAPI) = 13.1x faster
66
+ 🎯 FastAPI (uvicorn):
67
+ Simple GET: 8,337 req/s | Latency: ~12ms
68
+ Parameterized: 7,413 req/s | Latency: ~13ms
69
+ Async Handlers: 8,337 req/s | Latency: ~12ms
70
70
 
71
- 🎯 Heavy Load (500 connections):
72
- Root Endpoint: 43,057 req/s (TurboAPI) vs 7,897 req/s (FastAPI) = 5.5x faster
73
- Simple Endpoint: 43,525 req/s (TurboAPI) vs 8,092 req/s (FastAPI) = 5.4x faster
74
- JSON Endpoint: 42,743 req/s (TurboAPI) vs 3,099 req/s (FastAPI) = 13.8x faster
71
+ 📊 Performance Comparison:
72
+ Sync Handlers: 9.0x faster than FastAPI 🚀🚀🚀
73
+ Async Handlers: 1.6x faster than FastAPI
74
+ Latency: 8.5x lower than FastAPI
75
75
 
76
76
  🚀 Summary:
77
77
  • Average speedup: 5-13x faster than FastAPI
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "turboapi"
7
- version = "0.3.21"
7
+ version = "0.3.24"
8
8
  description = "Revolutionary Python web framework with FastAPI syntax and 5-10x performance (Python 3.13+ free-threading required)"
9
9
  requires-python = ">=3.13"
10
10
  license = {text = "MIT"}
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "turboapi"
7
- version = "0.3.21"
7
+ version = "0.3.24"
8
8
  description = "Revolutionary Python web framework with FastAPI syntax and 5-10x performance (Python 3.13+ free-threading required)"
9
9
  requires-python = ">=3.13"
10
10
  license = {text = "MIT"}
@@ -415,6 +415,7 @@ pub fn configure_rate_limiting(enabled: bool, requests_per_minute: Option<u32>)
415
415
 
416
416
  /// PHASE 2: Fast Python handler call with cached modules and optimized object creation
417
417
  /// Now supports async Python handlers via pyo3-async-runtimes + tokio
418
+ /// FREE-THREADING: Uses Python::attach() for true parallelism on Python 3.13+
418
419
  fn call_python_handler_fast(
419
420
  handler: Handler,
420
421
  method_str: &str,
@@ -422,7 +423,9 @@ fn call_python_handler_fast(
422
423
  query_string: &str,
423
424
  body: &Bytes
424
425
  ) -> Result<String, pyo3::PyErr> {
425
- Python::with_gil(|py| {
426
+ // Use Python::attach() instead of with_gil() for free-threading parallelism!
427
+ // This allows multiple Python handlers to run in parallel on Python 3.13+
428
+ Python::attach(|py| {
426
429
  // Get cached modules (initialized once)
427
430
  let types_module = CACHED_TYPES_MODULE.get_or_init(|| {
428
431
  py.import("types").unwrap().into()
@@ -465,10 +468,20 @@ fn call_python_handler_fast(
465
468
 
466
469
  // Handle sync vs async results differently
467
470
  if is_coroutine {
468
- // Async handler - we need to await the coroutine in an async context
469
- let asyncio = py.import("asyncio")?;
470
- let asyncio_run = asyncio.getattr("run")?;
471
- let awaited_result = asyncio_run.call1((result.clone_ref(py),))?;
471
+ // Async handler - use pyo3-async-runtimes for tokio integration
472
+ // NOTE: Still uses block_in_place() - true async requires making handle_request async
473
+ // Current performance: ~13K RPS (vs 72K for sync)
474
+ // Future optimization: Make entire request pipeline async (v0.4.0)
475
+
476
+ // Convert Python coroutine to Rust future using pyo3-async-runtimes
477
+ let rust_future = pyo3_async_runtimes::tokio::into_future(result.clone_ref(py).into_bound(py))?;
478
+
479
+ // Await the future (releases Python but blocks tokio thread)
480
+ let awaited_result = py.allow_threads(|| {
481
+ tokio::task::block_in_place(|| {
482
+ tokio::runtime::Handle::current().block_on(rust_future)
483
+ })
484
+ })?;
472
485
 
473
486
  // Serialize the awaited result
474
487
  let json_dumps = json_module.getattr(py, "dumps")?;
@@ -0,0 +1,64 @@
1
+ #!/bin/bash
2
+ # Async benchmark: TurboAPI v0.3.21 SYNC vs ASYNC vs FastAPI
3
+
4
+ echo "=========================================="
5
+ echo "🏁 TurboAPI v0.3.21: SYNC vs ASYNC vs FastAPI"
6
+ echo "=========================================="
7
+ echo ""
8
+
9
+ # Check for wrk
10
+ if ! command -v wrk &> /dev/null; then
11
+ echo "❌ wrk not found. Install with: brew install wrk"
12
+ exit 1
13
+ fi
14
+
15
+ # Test TurboAPI SYNC
16
+ echo "🚀 Test 1: TurboAPI SYNC (baseline)"
17
+ echo "=========================================="
18
+ python tests/test_v0_3_20_server.py > /tmp/turbo_sync.log 2>&1 &
19
+ TURBO_SYNC_PID=$!
20
+ sleep 4
21
+
22
+ echo "Simple GET:"
23
+ wrk -t4 -c100 -d10s http://127.0.0.1:8080/ 2>&1 | grep "Requests/sec"
24
+ echo "Parameterized:"
25
+ wrk -t4 -c100 -d10s http://127.0.0.1:8080/users/123 2>&1 | grep "Requests/sec"
26
+
27
+ kill $TURBO_SYNC_PID 2>/dev/null
28
+ sleep 2
29
+
30
+ # Test TurboAPI ASYNC
31
+ echo ""
32
+ echo "🚀 Test 2: TurboAPI ASYNC (asyncio.run)"
33
+ echo "=========================================="
34
+ python tests/test_async_benchmark.py > /tmp/turbo_async.log 2>&1 &
35
+ TURBO_ASYNC_PID=$!
36
+ sleep 4
37
+
38
+ echo "Simple GET:"
39
+ wrk -t4 -c100 -d10s http://127.0.0.1:8082/ 2>&1 | grep "Requests/sec"
40
+ echo "Parameterized:"
41
+ wrk -t4 -c100 -d10s http://127.0.0.1:8082/users/123 2>&1 | grep "Requests/sec"
42
+
43
+ kill $TURBO_ASYNC_PID 2>/dev/null
44
+ sleep 2
45
+
46
+ # Test FastAPI
47
+ echo ""
48
+ echo "🚀 Test 3: FastAPI (async with uvicorn)"
49
+ echo "=========================================="
50
+ python tests/fastapi_v0_3_20_equivalent.py > /tmp/fastapi.log 2>&1 &
51
+ FASTAPI_PID=$!
52
+ sleep 4
53
+
54
+ echo "Simple GET:"
55
+ wrk -t4 -c100 -d10s http://127.0.0.1:8081/ 2>&1 | grep "Requests/sec"
56
+ echo "Parameterized:"
57
+ wrk -t4 -c100 -d10s http://127.0.0.1:8081/users/123 2>&1 | grep "Requests/sec"
58
+
59
+ kill $FASTAPI_PID 2>/dev/null
60
+
61
+ echo ""
62
+ echo "=========================================="
63
+ echo "✅ Benchmark Complete!"
64
+ echo "=========================================="
@@ -0,0 +1,63 @@
1
+ #!/bin/bash
2
+ # Quick benchmark: TurboAPI v0.3.21 vs FastAPI
3
+
4
+ echo "=========================================="
5
+ echo "🏁 TurboAPI v0.3.21 vs FastAPI Benchmark"
6
+ echo "=========================================="
7
+ echo ""
8
+
9
+ # Check for wrk
10
+ if ! command -v wrk &> /dev/null; then
11
+ echo "❌ wrk not found. Install with: brew install wrk"
12
+ exit 1
13
+ fi
14
+
15
+ # Test TurboAPI
16
+ echo "🚀 Starting TurboAPI v0.3.21..."
17
+ python tests/test_v0_3_20_server.py > /tmp/turbo.log 2>&1 &
18
+ TURBO_PID=$!
19
+ sleep 4
20
+
21
+ echo "📊 Benchmarking TurboAPI (10s, 4 threads, 100 connections)..."
22
+ echo ""
23
+ echo "Test 1: Simple GET /"
24
+ wrk -t4 -c100 -d10s --latency http://127.0.0.1:8080/ 2>&1 | grep -E "Requests/sec|Latency|Thread"
25
+
26
+ echo ""
27
+ echo "Test 2: Parameterized route /users/123"
28
+ wrk -t4 -c100 -d10s --latency http://127.0.0.1:8080/users/123 2>&1 | grep -E "Requests/sec|Latency|Thread"
29
+
30
+ echo ""
31
+ echo "Test 3: Nested params /api/v1/users/1/posts/2"
32
+ wrk -t4 -c100 -d10s --latency http://127.0.0.1:8080/api/v1/users/1/posts/2 2>&1 | grep -E "Requests/sec|Latency|Thread"
33
+
34
+ kill $TURBO_PID 2>/dev/null
35
+ sleep 2
36
+
37
+ # Test FastAPI
38
+ echo ""
39
+ echo "=========================================="
40
+ echo "🚀 Starting FastAPI..."
41
+ python tests/fastapi_v0_3_20_equivalent.py > /tmp/fastapi.log 2>&1 &
42
+ FASTAPI_PID=$!
43
+ sleep 4
44
+
45
+ echo "📊 Benchmarking FastAPI (10s, 4 threads, 100 connections)..."
46
+ echo ""
47
+ echo "Test 1: Simple GET /"
48
+ wrk -t4 -c100 -d10s --latency http://127.0.0.1:8081/ 2>&1 | grep -E "Requests/sec|Latency|Thread"
49
+
50
+ echo ""
51
+ echo "Test 2: Parameterized route /users/123"
52
+ wrk -t4 -c100 -d10s --latency http://127.0.0.1:8081/users/123 2>&1 | grep -E "Requests/sec|Latency|Thread"
53
+
54
+ echo ""
55
+ echo "Test 3: Nested params /api/v1/users/1/posts/2"
56
+ wrk -t4 -c100 -d10s --latency http://127.0.0.1:8081/api/v1/users/1/posts/2 2>&1 | grep -E "Requests/sec|Latency|Thread"
57
+
58
+ kill $FASTAPI_PID 2>/dev/null
59
+
60
+ echo ""
61
+ echo "=========================================="
62
+ echo "✅ Benchmark Complete!"
63
+ echo "=========================================="
@@ -0,0 +1,55 @@
1
+ """
2
+ TurboAPI v0.3.21 ASYNC Benchmark Server
3
+ Tests async handler performance with asyncio.run()
4
+ """
5
+ import asyncio
6
+ from turboapi import TurboAPI
7
+
8
+ app = TurboAPI(title="TurboAPI v0.3.21 ASYNC Benchmark", version="0.3.21")
9
+
10
+ # Simple async GET
11
+ @app.get("/")
12
+ async def root():
13
+ await asyncio.sleep(0.0001) # Minimal async work
14
+ return {"message": "Hello, World!", "version": "0.3.21", "async": True}
15
+
16
+ # Async parameterized route
17
+ @app.get("/users/{user_id}")
18
+ async def get_user(user_id: int):
19
+ await asyncio.sleep(0.0001)
20
+ return {"user_id": user_id, "name": f"User {user_id}", "status": "active", "async": True}
21
+
22
+ # Async computation
23
+ @app.get("/compute")
24
+ async def compute():
25
+ await asyncio.sleep(0.0001)
26
+ result = sum(i * i for i in range(100))
27
+ return {"result": result, "type": "async_compute"}
28
+
29
+ # Async nested params
30
+ @app.get("/api/v1/users/{user_id}/posts/{post_id}")
31
+ async def get_user_post(user_id: int, post_id: int):
32
+ await asyncio.sleep(0.0001)
33
+ return {
34
+ "user_id": user_id,
35
+ "post_id": post_id,
36
+ "title": f"Post {post_id} by User {user_id}",
37
+ "async": True
38
+ }
39
+
40
+ if __name__ == "__main__":
41
+ print("=" * 70)
42
+ print("TurboAPI v0.3.21 ASYNC Benchmark Server")
43
+ print("=" * 70)
44
+ print("Endpoints (ALL ASYNC):")
45
+ print(" GET / - Simple async response")
46
+ print(" GET /users/{id} - Async parameterized route")
47
+ print(" GET /compute - Async computation")
48
+ print(" GET /api/v1/users/{uid}/posts/{pid} - Async nested params")
49
+ print("=" * 70)
50
+ print("⚠️ RATE LIMITING: DISABLED for benchmarking")
51
+ print("⚠️ Using asyncio.run() - expect some overhead")
52
+ print("=" * 70)
53
+
54
+ app.configure_rate_limiting(enabled=False)
55
+ app.run(host="127.0.0.1", port=8082)
@@ -2,10 +2,9 @@
2
2
  TurboAPI v0.3.20 Test Server for wrk benchmarking
3
3
  Tests both sync and async handlers with parameterized routes
4
4
  """
5
- import asyncio
6
5
  from turboapi import TurboAPI
7
6
 
8
- app = TurboAPI(title="TurboAPI v0.3.20 Benchmark", version="0.3.20")
7
+ app = TurboAPI(title="TurboAPI v0.3.21 Benchmark", version="0.3.21")
9
8
 
10
9
  # Simple GET (baseline)
11
10
  @app.get("/")
@@ -40,15 +39,17 @@ def echo(message: str = ""):
40
39
 
41
40
  if __name__ == "__main__":
42
41
  print("=" * 70)
43
- print("TurboAPI v0.3.20 Benchmark Server")
42
+ print("TurboAPI v0.3.21 Benchmark Server (SYNC ONLY)")
44
43
  print("=" * 70)
45
44
  print("Endpoints:")
46
45
  print(" GET / - Simple response")
47
- print(" GET /users/{id} - Parameterized route (NEW)")
46
+ print(" GET /users/{id} - Parameterized route")
48
47
  print(" GET /compute - Computation")
49
- print(" GET /api/v1/users/{uid}/posts/{pid} - Nested params (NEW)")
48
+ print(" GET /api/v1/users/{uid}/posts/{pid} - Nested params")
50
49
  print(" POST /echo - Body parsing")
51
50
  print("=" * 70)
51
+ print("⚠️ RATE LIMITING: DISABLED for benchmarking")
52
+ print("=" * 70)
52
53
 
53
54
  app.configure_rate_limiting(enabled=False)
54
55
  app.run(host="127.0.0.1", port=8080)
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes