Last active
May 1, 2019 20:57
-
-
Save mikf/fc29e3e461ddd74e30a9d33fcd01d4ee to your computer and use it in GitHub Desktop.
urllib3 rfc3986 compile times
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| import urllib3.packages.rfc3986.misc | |
| import time | |
| import re | |
| re_type = type(re.compile("")) | |
| results = [] | |
| for k, v in urllib3.packages.rfc3986.misc.__dict__.items(): | |
| if not isinstance(v, re_type): | |
| continue | |
| re.purge() | |
| t1 = time.time() | |
| re.compile(v.pattern) | |
| t2 = time.time() | |
| results.append(((t2 - t1) * 1000, k)) | |
| total = sum(x[0] for x in results) | |
| results.append((total, "TOTAL")) | |
| results.sort(key=lambda x: x[0], reverse=True) | |
| for duration, name in results: | |
| print("{:<24}: {:> 8.3f} ms {:> 7.2f} %".format( | |
| name, duration, duration / total * 100)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| TOTAL : 315.542 ms 100.00 % | |
| RELATIVE_IRI_MATCHER : 67.096 ms 21.26 % | |
| IPATH_MATCHER : 66.270 ms 21.00 % | |
| ABSOLUTE_IRI_MATCHER : 58.341 ms 18.49 % | |
| ISUBAUTHORITY_MATCHER : 29.682 ms 9.41 % | |
| IHOST_MATCHER : 19.188 ms 6.08 % | |
| SUBAUTHORITY_MATCHER : 11.993 ms 3.80 % | |
| HOST_MATCHER : 10.582 ms 3.35 % | |
| IQUERY_MATCHER : 10.152 ms 3.22 % | |
| IPv6_NO_RFC4007_MATCHER : 9.299 ms 2.95 % | |
| IPv6_MATCHER : 9.267 ms 2.94 % | |
| IFRAGMENT_MATCHER : 9.221 ms 2.92 % | |
| RELATIVE_REF_MATCHER : 3.642 ms 1.15 % | |
| PATH_MATCHER : 3.499 ms 1.11 % | |
| ABSOLUTE_URI_MATCHER : 3.313 ms 1.05 % | |
| URI_MATCHER : 1.217 ms 0.39 % | |
| IRI_MATCHER : 1.070 ms 0.34 % | |
| FRAGMENT_MATCHER : 0.515 ms 0.16 % | |
| QUERY_MATCHER : 0.505 ms 0.16 % | |
| IPv4_MATCHER : 0.409 ms 0.13 % | |
| SCHEME_MATCHER : 0.281 ms 0.09 % |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The results of this small script on the RPI:
TOTAL : 3547.403 ms 100.00 %
RELATIVE_IRI_MATCHER : 924.956 ms 26.07 %
IPATH_MATCHER : 915.648 ms 25.81 %
ABSOLUTE_IRI_MATCHER : 767.717 ms 21.64 %
ISUBAUTHORITY_MATCHER : 301.554 ms 8.50 %
IHOST_MATCHER : 167.904 ms 4.73 %
IQUERY_MATCHER : 144.590 ms 4.08 %
IFRAGMENT_MATCHER : 128.408 ms 3.62 %
HOST_MATCHER : 40.204 ms 1.13 %
SUBAUTHORITY_MATCHER : 39.271 ms 1.11 %
IPv6_MATCHER : 34.756 ms 0.98 %
IPv6_NO_RFC4007_MATCHER : 30.918 ms 0.87 %
RELATIVE_REF_MATCHER : 13.466 ms 0.38 %
PATH_MATCHER : 12.558 ms 0.35 %
ABSOLUTE_URI_MATCHER : 11.449 ms 0.32 %
URI_MATCHER : 4.315 ms 0.12 %
IRI_MATCHER : 3.943 ms 0.11 %
QUERY_MATCHER : 1.718 ms 0.05 %
FRAGMENT_MATCHER : 1.708 ms 0.05 %
IPv4_MATCHER : 1.425 ms 0.04 %
SCHEME_MATCHER : 0.895 ms 0.03 %
And the following script:
import time
t1 = time.time()
import urllib3.packages.rfc3986.misc
t2 = time.time()
print t2 - t1
Gives: 3.82467889786