Closed virtosubogdan closed 3 years ago
The cssutils library used for sami takes a long time to load (0.5s) and this affects tests especially. In some cases you might not even need sami conversion. It would be easy to load this library only when necessary. Would a PR to fix this be ok ?
For pycaption 0.7.4:
import cProfile, pstats p = cProfile.Profile() p.enable() import pycaption p.disable() pstats.Stats(p).sort_stats('cumulative').print_stats(20)
Ordered by: cumulative time List reduced from 804 to 20 due to restriction <20> ncalls tottime percall cumtime percall filename:lineno(function) 1 0.001 0.001 0.597 0.597 /build/deployed/local/lib/python2.7/site-packages/pycaption/__init__.py:1(<module>) 1144 0.008 0.000 0.527 0.000 /build/deployed/lib/python2.7/re.py:230(_compile) 1 0.001 0.001 0.526 0.526 /build/deployed/local/lib/python2.7/site-packages/pycaption/sami.py:37(<module>) 244 0.001 0.000 0.525 0.002 /build/deployed/lib/python2.7/re.py:192(compile) 1 0.001 0.001 0.525 0.525 /build/deployed/local/lib/python2.7/site-packages/cssutils/__init__.py:90(<module>) 208 0.001 0.000 0.519 0.002 /build/deployed/lib/python2.7/sre_compile.py:567(compile) 1 0.000 0.000 0.489 0.489 /build/deployed/local/lib/python2.7/site-packages/cssutils/profiles.py:136(__init__) 1 0.000 0.000 0.489 0.489 /build/deployed/local/lib/python2.7/site-packages/cssutils/profiles.py:278(addProfiles) 9 0.000 0.000 0.489 0.054 /build/deployed/local/lib/python2.7/site-packages/cssutils/profiles.py:294(addProfile) 9 0.001 0.000 0.477 0.053 /build/deployed/local/lib/python2.7/site-packages/cssutils/profiles.py:208(_compile_regexes) 208 0.001 0.000 0.278 0.001 /build/deployed/lib/python2.7/sre_parse.py:706(parse) 3438/208 0.023 0.000 0.276 0.001 /build/deployed/lib/python2.7/sre_parse.py:317(_parse_sub) 10028/212 0.104 0.000 0.275 0.001 /build/deployed/lib/python2.7/sre_parse.py:395(_parse) 208 0.000 0.000 0.239 0.001 /build/deployed/lib/python2.7/sre_compile.py:552(_code) 15721/208 0.106 0.000 0.194 0.001 /build/deployed/lib/python2.7/sre_compile.py:64(_compile) 1 0.000 0.000 0.067 0.067 /build/deployed/local/lib/python2.7/site-packages/pycaption/dfxp/__init__.py:1(<module>) 1 0.001 0.001 0.066 0.066 /build/deployed/local/lib/python2.7/site-packages/pycaption/dfxp/base.py:1(<module>) 62980 0.019 0.000 0.065 0.000 /build/deployed/lib/python2.7/sre_parse.py:212(get) 79541 0.048 0.000 0.058 0.000 /build/deployed/lib/python2.7/sre_parse.py:193(__next) 1 0.000 0.000 0.053 0.053 /build/deployed/local/lib/python2.7/site-packages/bs4/__init__.py:18(<module>)```
The cssutils library used for sami takes a long time to load (0.5s) and this affects tests especially. In some cases you might not even need sami conversion. It would be easy to load this library only when necessary. Would a PR to fix this be ok ?
For pycaption 0.7.4: