Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: stop use re on get_route_path #2701

Merged
merged 3 commits into from
Sep 23, 2024
Merged

perf: stop use re on get_route_path #2701

merged 3 commits into from
Sep 23, 2024

Conversation

trim21
Copy link
Contributor

@trim21 trim21 commented Sep 23, 2024

Summary

platform win32 -- Python 3.10.11, pytest-8.3.2, pluggy-1.5.0
benchmark: 4.0.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: C:\Users\Trim21\proj\starlette
configfile: pyproject.toml
plugins: anyio-4.6.0, benchmark-4.0.0
collected 9 items                                                                                                                                                                                                              

bench.py .........                                                                                                                                                                                                       [100%]


----------------------------------------------------------------------------------------------------- benchmark: 6 tests -----------------------------------------------------------------------------------------------------  
Name (time in ns)                                 Min                    Max                Mean              StdDev              Median                 IQR              Outliers  OPS (Mops/s)            Rounds  Iterations  
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  
test_benchmark_new_same                      155.0000 (1.0)         896.0004 (1.0)      168.0182 (1.0)       16.1868 (1.0)      165.0001 (1.0)        2.0006 (34.37)     3410;6140        5.9517 (1.0)       59881         100  
test_benchmark_new_prefix_non_path_match     191.6633 (1.24)      8,683.3315 (9.69)     217.1695 (1.29)      45.3998 (2.80)     208.3349 (1.26)       8.3334 (143.17)    6589;9667        4.6047 (0.77)     196080          12  
test_benchmark_new_path_match                236.8408 (1.53)      3,373.6823 (3.77)     264.6139 (1.57)      42.3720 (2.62)     257.8936 (1.56)      10.5264 (180.84)  10082;11053        3.7791 (0.63)     192309          19  
test_benchmark_old_prefix_non_path_match     749.9960 (4.84)      8,500.0065 (9.49)     820.3344 (4.88)     138.4135 (8.55)     799.9964 (4.85)      16.6668 (286.33)   9095;10933        1.2190 (0.20)     192309           6  
test_benchmark_old_path_match                799.9479 (5.16)     48,399.9611 (54.02)    962.8631 (5.73)     314.3289 (19.42)    900.0069 (5.45)     100.0008 (>1000.0)   3969;5611        1.0386 (0.17)     181819           1  
test_benchmark_old_same                      799.9479 (5.16)      9,899.9590 (11.05)    898.1221 (5.35)     183.1213 (11.31)    900.0069 (5.45)       0.0582 (1.0)        197;2092        1.1134 (0.19)       7988           1  
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------  

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean

@Kludex
Copy link
Member

Kludex commented Sep 23, 2024

Does this by any chance solves this: #2541 (comment) ?

@trim21
Copy link
Contributor Author

trim21 commented Sep 23, 2024

Does this by any chance solves this: #2541 (comment) ?

it's a plain str prefix check, no interpretation is made.

@trim21
Copy link
Contributor Author

trim21 commented Sep 23, 2024

Does this by any chance solves this: #2541 (comment) ?

I think it fix the original post, root_path contains any regex special chars, for example . or *

But not root_path="/{username}".

Copy link
Member

@Kludex Kludex left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @trim21 🙏

@Kludex Kludex merged commit d289ac7 into encode:master Sep 23, 2024
6 checks passed
@trim21 trim21 deleted the perf branch September 23, 2024 18:24
nixroxursox pushed a commit to nixroxursox/starlette that referenced this pull request Sep 30, 2024
* perf: stop use re on get_route_path

* add test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants