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

stdLambda #performance #51

Closed
ws-garcia opened this issue Jan 14, 2022 · 2 comments
Closed

stdLambda #performance #51

ws-garcia opened this issue Jan 14, 2022 · 2 comments
Labels
duplicate This issue or pull request already exists

Comments

@ws-garcia
Copy link

I have been playing with stdLambda and a doubt is gnawing my head. Why is the evaluation of a function like sin(x) so slow compared to numeric evaluation in this class module, given the fact it is a single operation?

@ws-garcia ws-garcia changed the title stdLambda **performance** stdLambda #performance Jan 14, 2022
@sancarn
Copy link
Owner

sancarn commented Jan 14, 2022

It's difficult to say for sure, it could be due to a number of reasons. Happy for help looking into exactly why. The relevant parts of the code are as follows:

  1. Function symbol
  2. Getting args off the stack
  3. Function evaluation

Some whatchouts:

  • Could be due to how much mem copying is going on, to prepare arguments etc.
  • If you've added any overrides in oFuncExt that'd be why, as there is a check that sin is overwritten in the late-bound dictionary:

    If TypeName(Me.oFunctExt) = "Dictionary" Then
        If Me.oFunctExt.exists(sFuncName) Then
            Dim vInjectedVar As Variant
            Call CopyVariant(vInjectedVar, oFunctExt(sFuncName))
            If TypeOf vInjectedVar Is stdICallable Then
                Call CopyVariant(evaluateFunc, Me.oFunctExt(sFuncName).RunEx(args))
            Else
                Call CopyVariant(evaluateFunc, vInjectedVar)
            End If
            Exit Function
        End If
    End If

so that's where i'd check first

In general though it's likely because at min-3 stack pops are required (Func symbol, argLength, arg + timeWhileEvaluating); where with standard numerical evaluation only 1 stack pop is required (arg).

@sancarn sancarn added the duplicate This issue or pull request already exists label Jan 21, 2022
@sancarn
Copy link
Owner

sancarn commented Jan 21, 2022

I've included this on the stdLambda performance megathread here:
#49 (comment)

Please use this issue in future.

@sancarn sancarn closed this as completed Jan 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants