-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 in LFOR/fhirpath.js from bugfix/LF-2253/extens…
…ion-for-primitive-types to master * commit 'a32eaf924c6c8f6e3c0c8048e034d882034c9752': Added a suite of performance tests for engine.MemberInvocation Fixed issues found during review Fixed "extension()" for primitive types not working properly without a value Added version number to fhirpath.js demo page Add language to make fixture valid Example of failing test with extensions
- Loading branch information
Showing
12 changed files
with
239 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,88 +1,89 @@ | ||
const b = require('benny'); | ||
const open = require('open'); | ||
|
||
const previous_fhirpath = require('./prev-fhirpath/node_modules/fhirpath'); | ||
const previous_r4_model = require('./prev-fhirpath/node_modules/fhirpath/fhir-context/r4'); | ||
const current_fhirpath = require('../../src/fhirpath'); | ||
const current_r4_model = require('../../fhir-context/r4'); | ||
const _ = require('lodash'); | ||
|
||
const minimumDataset = require('../resources/Minimum-Data-Set---version-3.0.R4.json'); | ||
|
||
const bigItems = current_fhirpath.evaluate(minimumDataset,'repeat(item)', {}, current_r4_model); | ||
const bigItemsCopy = _.cloneDeep(bigItems); | ||
const numberOfBigItems = current_fhirpath.evaluate({}, '%items.count()', { items: bigItems }, current_r4_model)[0]; | ||
module.exports = ({ | ||
benny, | ||
open, | ||
previous_fhirpath, | ||
previous_r4_model, | ||
current_fhirpath, | ||
current_r4_model, | ||
minimumDataset, | ||
currentVersion, | ||
previousVersion | ||
}) => { | ||
|
||
const smallItems = current_fhirpath.evaluate(minimumDataset,'repeat(item).repeat(code)', {}, current_r4_model); | ||
const smallItemsCopy = _.cloneDeep(smallItems); | ||
const numberOfSmallItems = current_fhirpath.evaluate({}, '%items.count()', { items: smallItems }, current_r4_model)[0]; | ||
const bigItems = current_fhirpath.evaluate(minimumDataset,'repeat(item)', {}, current_r4_model); | ||
const bigItemsCopy = _.cloneDeep(bigItems); | ||
const numberOfBigItems = current_fhirpath.evaluate({}, '%items.count()', { items: bigItems }, current_r4_model)[0]; | ||
|
||
const previousVersion = require('./prev-fhirpath/node_modules/fhirpath/package.json').version; | ||
const currentVersion = require('../../package.json').version; | ||
const smallItems = current_fhirpath.evaluate(minimumDataset,'repeat(item).repeat(code)', {}, current_r4_model); | ||
const smallItemsCopy = _.cloneDeep(smallItems); | ||
const numberOfSmallItems = current_fhirpath.evaluate({}, '%items.count()', { items: smallItems }, current_r4_model)[0]; | ||
|
||
const expression = '%items.intersect(%itemsCopy)'; | ||
const expression = '%items.intersect(%itemsCopy)'; | ||
|
||
const cases = [ | ||
{ | ||
name: `${numberOfBigItems} big items using evaluate()`, | ||
testFunction: (fhirpath, model) => { | ||
fhirpath.evaluate({}, expression, { items: bigItems, itemsCopy: bigItemsCopy }, model); | ||
} | ||
}, | ||
{ | ||
name: `${numberOfBigItems} big items using compile()`, | ||
testFunction: (fhirpath, model, compiledFn) => { | ||
compiledFn({}, { items: bigItems, itemsCopy: bigItemsCopy }); | ||
} | ||
}, | ||
{ | ||
name: `${numberOfSmallItems} small items using evaluate()`, | ||
testFunction: (fhirpath, model) => { | ||
fhirpath.evaluate({}, expression, { items: smallItems, itemsCopy: smallItemsCopy }, model); | ||
} | ||
}, | ||
{ | ||
name: `${numberOfSmallItems} small items using compile()`, | ||
testFunction: (fhirpath, model, compiledFn) => { | ||
compiledFn({}, { items: smallItems, itemsCopy: smallItemsCopy }); | ||
const cases = [ | ||
{ | ||
name: `${numberOfBigItems} big items using evaluate()`, | ||
testFunction: (fhirpath, model) => { | ||
fhirpath.evaluate({}, expression, { items: bigItems, itemsCopy: bigItemsCopy }, model); | ||
} | ||
}, | ||
{ | ||
name: `${numberOfBigItems} big items using compile()`, | ||
testFunction: (fhirpath, model, compiledFn) => { | ||
compiledFn({}, { items: bigItems, itemsCopy: bigItemsCopy }); | ||
} | ||
}, | ||
{ | ||
name: `${numberOfSmallItems} small items using evaluate()`, | ||
testFunction: (fhirpath, model) => { | ||
fhirpath.evaluate({}, expression, { items: smallItems, itemsCopy: smallItemsCopy }, model); | ||
} | ||
}, | ||
{ | ||
name: `${numberOfSmallItems} small items using compile()`, | ||
testFunction: (fhirpath, model, compiledFn) => { | ||
compiledFn({}, { items: smallItems, itemsCopy: smallItemsCopy }); | ||
} | ||
} | ||
} | ||
].reduce((arr, item) => { | ||
arr.push( | ||
b.add( | ||
`${item.name} [${previousVersion}]`, | ||
item.testFunction.bind( | ||
this, | ||
previous_fhirpath, | ||
previous_r4_model, | ||
previous_fhirpath.compile(expression, previous_r4_model) | ||
].reduce((arr, item) => { | ||
arr.push( | ||
benny.add( | ||
`${item.name} [${previousVersion}]`, | ||
item.testFunction.bind( | ||
this, | ||
previous_fhirpath, | ||
previous_r4_model, | ||
previous_fhirpath.compile(expression, previous_r4_model) | ||
) | ||
) | ||
) | ||
); | ||
arr.push( | ||
b.add( | ||
`${item.name} [${currentVersion}]`, | ||
item.testFunction.bind( | ||
this, | ||
current_fhirpath, | ||
current_r4_model, | ||
current_fhirpath.compile(expression, current_r4_model) | ||
); | ||
arr.push( | ||
benny.add( | ||
`${item.name} [${currentVersion}]`, | ||
item.testFunction.bind( | ||
this, | ||
current_fhirpath, | ||
current_r4_model, | ||
current_fhirpath.compile(expression, current_r4_model) | ||
) | ||
) | ||
) | ||
); | ||
return arr; | ||
}, []); | ||
); | ||
return arr; | ||
}, []); | ||
|
||
b.suite( | ||
'intersect() of two collections with', | ||
...cases, | ||
b.cycle(), | ||
b.complete(), | ||
b.configure({ | ||
minDisplayPrecision: 2 | ||
}), | ||
b.save({ file: 'intersect', folder: __dirname + '/results', version: currentVersion }), | ||
b.save({ file: 'intersect', folder: __dirname + '/results', format: 'chart.html' }), | ||
).then(() => { | ||
open(__dirname + '/results/intersect.chart.html'); | ||
}); | ||
benny.suite( | ||
'intersect() of two collections with', | ||
...cases, | ||
benny.cycle(), | ||
benny.complete(), | ||
benny.configure({ | ||
minDisplayPrecision: 2 | ||
}), | ||
benny.save({ file: 'intersect', folder: __dirname + '/results', version: currentVersion }), | ||
benny.save({ file: 'intersect', folder: __dirname + '/results', format: 'chart.html' }), | ||
).then(() => { | ||
open(__dirname + '/results/intersect.chart.html'); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
const _ = require('lodash'); | ||
|
||
module.exports = ({ | ||
benny, | ||
open, | ||
previous_fhirpath, | ||
previous_r4_model, | ||
current_fhirpath, | ||
current_r4_model, | ||
minimumDataset, | ||
currentVersion, | ||
previousVersion | ||
}) => { | ||
|
||
const numberOfItems = current_fhirpath.evaluate(minimumDataset,'Questionnaire.item.count()', {}, current_r4_model); | ||
const expression = 'Questionnaire.item'; | ||
|
||
const cases = [ | ||
{ | ||
name: `using evaluate()`, | ||
testFunction: (fhirpath, model) => { | ||
fhirpath.evaluate(minimumDataset, expression, {}, model); | ||
} | ||
}, | ||
{ | ||
name: `using compile()`, | ||
testFunction: (fhirpath, model, compiledFn) => { | ||
compiledFn(minimumDataset, {}); | ||
} | ||
} | ||
].reduce((arr, item) => { | ||
arr.push( | ||
benny.add( | ||
`${item.name} [${previousVersion}]`, | ||
item.testFunction.bind( | ||
this, | ||
previous_fhirpath, | ||
previous_r4_model, | ||
previous_fhirpath.compile(expression, previous_r4_model) | ||
) | ||
) | ||
); | ||
arr.push( | ||
benny.add( | ||
`${item.name} [${currentVersion}]`, | ||
item.testFunction.bind( | ||
this, | ||
current_fhirpath, | ||
current_r4_model, | ||
current_fhirpath.compile(expression, current_r4_model) | ||
) | ||
) | ||
); | ||
return arr; | ||
}, []); | ||
|
||
benny.suite( | ||
`Getting ${numberOfItems} items with engine.MemberInvocation`, | ||
...cases, | ||
benny.cycle(), | ||
benny.complete(), | ||
benny.configure({ | ||
minDisplayPrecision: 2 | ||
}), | ||
benny.save({ file: 'member-invocation', folder: __dirname + '/results', version: currentVersion }), | ||
benny.save({ file: 'member-invocation', folder: __dirname + '/results', format: 'chart.html' }), | ||
).then(() => { | ||
open(__dirname + '/results/member-invocation.chart.html'); | ||
}); | ||
} |
Oops, something went wrong.