`stdLambda` performance re-visited
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 25/100
- Tipo de issue
- Refactorización
- Claridad
- Necesita aclaración
- Estado de actividad
- Estancado
- Stack tecnológico
- visualbasic
- Área
- performance
Línea de trabajo
The issue provides a VBA benchmark comparing stdLambda with clsMathParser, but names no source files or tests. Start by reproducing the supplied benchmark and reading the stdLambda implementation and commit 2a9b2e0. Done is not defined; the issue suggests investigating a pre-populated stack and other performance differences without selecting a concrete change.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
stdLambda Performance
It has come to my attention that there exists another library a lot like stdLambda, named clsMathParser. This library apparently existed since 2004(?!), so totally unsure how this skipped passed my radar! It's not a very intuitive library but essentially functions as follows:
With new clsMathParser
.storeExpression("x+1")
For i = 1 to 100
variable("x") = i
Debug.Print .eval()
next
End With
This library is, according to my testing, 5x vaster than stdLambda. Test set:
Sub test()
Dim math As New clsMathParser
Dim lambda As stdLambda: Set lambda = stdLambda.Create("$1^2+$1+2")
If math.StoreExpression("x^2+x+2") Then
With stdPerformance.Measure("clsMathParser", 10000)
Dim i As Double, l As Double
For i = 1 To 1000000
math.variable("x") = i / 1000
l = math.Eval()
Next
End With
With stdPerformance.Measure("stdLambda", 10000)
For i = 1 To 1000000
l = lambda.Run(i / 1000)
Next
End With
End If
End Sub
Comparrison of algorithm
clsMathParser's stack is pre-populated with values paired with operators. This ultimately means less operations done in VBA side:clsMathParsersplitsx^2+x+2into 3 operations:ET(0)= completion opET(1)=^prevArg + varX^2(???)ET(2)=+prevArg + varXET(3)=+0+2
stdLambdasplits$1^2+$1+2into 7 operationsops(0)= Arg 1ops(1)= Push 2ops(2)= Op Powops(3)= Arg 1ops(4)= Op Addops(5)= Push 2ops(6)= Op Addops(7)= Completion
stdLambda's starts with an empty stack and alocates it with values at runtime. Though we're only copying a few bytes I guess this consumes a lot of time compared to having all that data pre-prepared. A pre-populated stack is something we should likely look into.stdLambdaused to be copying argument location from a string at runtime, which is slow! I changed this and it saves some 30µs per operation. Fixed in 2a9b2e0clsMathParserisn't stand alone sadly, and doesn't provide object access.stdLambdadoes provide object access and is standalone by comparrison (although technically requiresstdICallable- easily removed by comparrison)- Cleverly
clsMathParseruses aByRefparam for the return type. That shaves off some time, although not significant in my tests. But still clever fosho :)
- Lenguaje dominante
- VBA
- Estrellas
- 412
- Forks
- 70
- Merge medio
- 16 h 10 min
- PR fusionados (30 d)
- 3
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de sancarn/stdVBA
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 77/100
-
Issues of stdRefArrayAbiertoenhancement
Dificultad 4/5 3-5 días Aptitud para principiantes 38/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
Todos los issues de sancarn/stdVBA
Issues similares
-
`XmlMaxs` serializes its XML node on every read, which makes `assemble` several times slowerAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
objectionary/jeo-maven-plugin#1931 ·
Los mantenedores suelen responder en 2 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 80/100
huggingface/transformers.js#1839 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 67/100
ly05010419/MacNativeGames#1332 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
SamuelNDCE/plume#42 ·
Los mantenedores suelen responder en 1 día
-
area: theme good first issue help wanted lane: free-agent roadmap size: XS type: task
Dificultad 2/5 1-3 horas Aptitud para principiantes 84/100
arminazimi/slipway#765 ·
Los mantenedores suelen responder en 1 día