Ajoute un test de performance

pull/138/head
Laurent Bossavit 2017-12-16 12:01:51 +01:00 committed by mama
parent 4fa9b8f685
commit d454e94ef6
2 changed files with 14 additions and 6 deletions

View File

@ -64,11 +64,8 @@ export let reduceSteps = (tracker, flatRules, answerSource) => (
let
parsedRules = R.path(['analysis', 'parsedRules'], state),
date = Date.now(),
analysis = analyseMany(state.parsedRules, targetNames)(situationWithDefaults(state)),
yaya = console.log('Date.now(', Date.now() - date),
nextWithDefaults = getNextSteps(situationWithDefaults(state), analysis),
yaaya = console.log('Date.now2(', Date.now() - date),
assumptionsMade = !R.isEmpty(rulesDefaults),
done = nextWithDefaults.length == 0
@ -86,7 +83,6 @@ export let reduceSteps = (tracker, flatRules, answerSource) => (
nextWithoutDefaults(state, analysis, targetNames, intermediateSituation)
: {currentQuestion: head(nextWithDefaults), nextSteps: nextWithDefaults, })
}
console.log('Date.now3(', Date.now() - date)
if (action.type == START_CONVERSATION) {
return {

View File

@ -1,6 +1,6 @@
import { expect } from "chai"
import { enrichRule } from "../source/engine/rules"
import { analyse, parseAll } from "../source/engine/traverse"
import { rules as realRules, enrichRule } from '../source/engine/rules'
import { analyse, analyseMany, parseAll } from "../source/engine/traverse"
import { collectMissingVariables } from "../source/engine/generateQuestions"
import yaml from "js-yaml"
import dedent from "dedent-js"
@ -198,3 +198,15 @@ it("complex inversion with composantes", () => {
expect(analysis.targets[0].nodeValue).to.equal(3750)
expect(missing).to.be.empty
})
it('should collect missing variables fast', function() {
let stateSelector = (name) => ({"contrat salarié . salaire net":"2300"})[name]
let rules = parseAll(realRules.map(enrichRule)),
analysis = analyseMany(rules,["salaire brut","salaire total"])(stateSelector)
let start = Date.now()
let missing = collectMissingVariables(analysis.targets)
let elapsed = Date.now()-start
expect(elapsed).to.be.below(200)
});