🐎 Ajout d'un cache pour l'applicabilité
En analysant les traces d'execution, il apparaît qu'un temps conséquent est passé dans la fonction `evaluateApplicability`. L'ajout d'un cache simple semble améliorer significativement les performances (environ -30% dans mes mesures non scientifiques).pull/1210/head
parent
5ed95920c3
commit
69b663d132
|
@ -5,6 +5,10 @@ import { bonus, mergeAllMissing, mergeMissing } from './evaluation'
|
|||
import { convertNodeToUnit } from './nodeUnits'
|
||||
|
||||
export const evaluateApplicability: evaluationFunction = function(node: any) {
|
||||
const cacheKey = `${node.dottedName} [applicability]`
|
||||
if (node.dottedName && this.cache[cacheKey]) {
|
||||
return this.cache[cacheKey]
|
||||
}
|
||||
const evaluatedAttributes = pipe(
|
||||
pick(['non applicable si', 'applicable si', 'rendu non applicable']) as (
|
||||
x: any
|
||||
|
@ -49,7 +53,7 @@ export const evaluateApplicability: evaluationFunction = function(node: any) {
|
|||
)
|
||||
}
|
||||
|
||||
return {
|
||||
const res = {
|
||||
...node,
|
||||
nodeValue,
|
||||
isApplicable: nodeValue,
|
||||
|
@ -57,6 +61,12 @@ export const evaluateApplicability: evaluationFunction = function(node: any) {
|
|||
parentDependencies,
|
||||
...evaluatedAttributes
|
||||
}
|
||||
|
||||
if (node.dottedName) {
|
||||
this.cache[cacheKey] = res
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
export const evaluateFormula: evaluationFunction = function(node) {
|
||||
|
|
Loading…
Reference in New Issue