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

Performance improvements for WMA, FWMA and Linreg #776

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

Rossco8
Copy link

@Rossco8 Rossco8 commented Mar 11, 2024

Code performance tested with cProfile

WMA original performance

120451 function calls (120437 primitive calls) in 0.073 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
     5001    0.015    0.000    0.046    0.000 base.py:5437(_can_hold_identifiers_and_holds_name)
     5003    0.009    0.000    0.056    0.000 generic.py:6281(__getattr__)
     1250    0.008    0.000    0.070    0.000 wma.py:65(_compute)
     5001    0.007    0.000    0.013    0.000 common.py:137(is_object_dtype)
     5001    0.006    0.000    0.012    0.000 common.py:1375(_is_dtype)
     5001    0.004    0.000    0.017    0.000 common.py:536(is_string_dtype)
     5001    0.004    0.000    0.005    0.000 common.py:572(condition)
     5001    0.004    0.000    0.005    0.000 common.py:1434(_is_dtype_type)
     2500    0.004    0.000    0.006    0.000 series.py:974(__array__)
        1    0.002    0.002    0.071    0.071 rolling.py:1531(apply_func)

WMA New Performance

309 function calls (300 primitive calls) in 0.002 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.001    0.001    0.001    0.001 base.py:2313(is_unique)
        1    0.000    0.000    0.000    0.000 base.py:842(_engine)
        1    0.000    0.000    0.000    0.000 base.py:5323(__contains__)
        1    0.000    0.000    0.000    0.000 wma.py:16(wma)
        1    0.000    0.000    0.001    0.001 frame.py:4050(__getitem__)
      4/2    0.000    0.000    0.000    0.000 {built-in method _abc._abc_subclasscheck}
        1    0.000    0.000    0.000    0.000 frame.py:3971(_ixs)
        1    0.000    0.000    0.002    0.002 {built-in method builtins.exec}
        1    0.000    0.000    0.000    0.000 frame.py:4614(_get_item_cache)
        1    0.000    0.000    0.000    0.000 managers.py:1012(iget)

FWMA original performance

2936 function calls (2925 primitive calls) in 0.005 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.002    0.002    0.003    0.003 rolling.py:1531(apply_func)
     1250    0.001    0.000    0.001    0.000 _math.py:249(_dot)
        1    0.000    0.000    0.001    0.001 base.py:2313(is_unique)
        1    0.000    0.000    0.000    0.000 base.py:5323(__contains__)
        2    0.000    0.000    0.000    0.000 {method 'reduce' of 'numpy.ufunc' objects}
        1    0.000    0.000    0.000    0.000 base.py:842(_engine)
     1250    0.000    0.000    0.000    0.000 multiarray.py:741(dot)
        1    0.000    0.000    0.004    0.004 fwma.py:15(fwma)
        1    0.000    0.000    0.000    0.000 _math.py:81(fibonacci)
        1    0.000    0.000    0.001    0.001 frame.py:4050(__getitem__)

FWMA new performance

398 function calls (389 primitive calls) in 0.002 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.001    0.001    0.001    0.001 base.py:2313(is_unique)
        1    0.000    0.000    0.000    0.000 base.py:842(_engine)
        1    0.000    0.000    0.000    0.000 base.py:5323(__contains__)
        1    0.000    0.000    0.000    0.000 fwma.py:15(fwma)
        1    0.000    0.000    0.000    0.000 frame.py:4614(_get_item_cache)
        1    0.000    0.000    0.000    0.000 _math.py:81(fibonacci)
        9    0.000    0.000    0.000    0.000 function_base.py:5563(append)
        1    0.000    0.000    0.001    0.001 frame.py:4050(__getitem__)
        1    0.000    0.000    0.000    0.000 frame.py:3971(_ixs)
        1    0.000    0.000    0.002    0.002 {built-in method builtins.exec}
        1    0.000    0.000    0.000    0.000 managers.py:1012(iget)

Linreg original performance

9017 function calls (9012 primitive calls) in 0.027 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.009    0.009    0.025    0.025 linreg.py:127(<listcomp>)
     1246    0.007    0.000    0.016    0.000 linreg.py:98(linear_regression)
     2492    0.005    0.000    0.008    0.000 {method 'sum' of 'numpy.ndarray' objects}
     2493    0.003    0.000    0.003    0.000 {method 'reduce' of 'numpy.ufunc' objects}
     2492    0.001    0.000    0.004    0.000 _methods.py:47(_sum)
        1    0.000    0.000    0.026    0.026 linreg.py:20(linreg)
        1    0.000    0.000    0.001    0.001 frame.py:4050(__getitem__)
        1    0.000    0.000    0.000    0.000 stride_tricks.py:123(sliding_window_view)
        1    0.000    0.000    0.027    0.027 {built-in method builtins.exec}
        1    0.000    0.000    0.000    0.000 cast.py:124(maybe_convert_platform)
        1    0.000    0.000    0.027    0.027 <string>:1(<module>)

Linreg new performance

272 function calls (267 primitive calls) in 0.003 seconds

   Ordered by: internal time

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
        1    0.001    0.001    0.002    0.002 linreg.py:14(linreg)
        1    0.000    0.000    0.000    0.000 stride_tricks.py:123(sliding_window_view)
        1    0.000    0.000    0.003    0.003 <string>:1(<module>)
        1    0.000    0.000    0.003    0.003 {built-in method builtins.exec}
        3    0.000    0.000    0.000    0.000 {method 'reduce' of 'numpy.ufunc' objects}
        1    0.000    0.000    0.001    0.001 frame.py:4050(__getitem__)
        1    0.000    0.000    0.000    0.000 managers.py:1012(iget)
        1    0.000    0.000    0.000    0.000 frame.py:3971(_ixs)
        1    0.000    0.000    0.000    0.000 stride_tricks.py:38(as_strided)
        1    0.000    0.000    0.001    0.001 frame.py:4614(_get_item_cache)
        1    0.000    0.000    0.000    0.000 series.py:389(__init__)

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.

1 participant