Improves performance of addition of contexts and addition of tests #217
+36
−16
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In my current project, I need to tests the results of a page with several thousand input cases. I have this cases in a test file and I decided to use canopy to dynamically create and run a test for each of them.
While doing this I have found that the functions that add tests are not efficient and adding several thousands of them will take a long time.
Concatenating two list to add a element, like in
is an
O(n)
operation wheren
is the size ofsuites
.So, concatenating
n
lists of size 1 is anO(n^2)
operation.Adding an element to a list, like in
is an
O(1)
operation.I have changed the concatenations to add an element to the end of a list, with an addition of the element to the front of the list. This have the effect that now the lists are in reverse order, so I also reversed the lists before using them in the
run
function.Reference
Mastering F# Lists