Skip to content

Improve Python Indicator Benchmark Performance Score #2925

@Martin-Molinero

Description

@Martin-Molinero

Expected Behavior

  • Py and C# performance score of the indicator benchmark, are as close as possible

Actual Behavior

Potential Solution

  • Profile and review hot spots:
    imagen

  • magic() and GetValue() are hot spots (PythonNet code https://github.com/QuantConnect/pythonnet).

    • GetValue() uses reflection to find and call the Getter method -> This could be cached. Same applies for the Setter method (even if not triggered by this benchmark)
    • ObjectOffset.magic() method returns an integer which is an offset. The returned int has two possible values depending on the python object type being an exception or not. -> we can have a type cache holding if its an exception or not.
      - The cache can also be used by ObjectOffset.DictOffset() and ObjectOffset.Size()

Reproducing the Problem

Execute Py and C# Indicator benchmark algorithms, https://github.com/QuantConnect/Lean/blob/master/Algorithm.Python/Benchmarks/IndicatorRibbonBenchmark.py

System Information

N/A

Checklist

  • I have completely filled out this template
  • I have confirmed that this issue exists on the current master branch
  • I have confirmed that this is not a duplicate issue by searching issues
  • I have provided detailed steps to reproduce the issue

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions