Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improves performance of addition of contexts and addition of tests #217

Merged
merged 4 commits into from
Oct 18, 2015
Merged

Improves performance of addition of contexts and addition of tests #217

merged 4 commits into from
Oct 18, 2015

Conversation

edhzsz
Copy link
Contributor

@edhzsz edhzsz commented Oct 17, 2015

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

suites <- suites @ [s]

is an O(n) operation where n is the size of suites.
So, concatenating n lists of size 1 is an O(n^2) operation.

Adding an element to a list, like in

suites <- s::suites

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

@lefthandedgoat
Copy link
Owner

Ah yes, I knew this would eventually be a problem, I am glad you running this many tests!

I am out of town right now. I will get a new build out for you tomorrow.

@edhzsz
Copy link
Contributor Author

edhzsz commented Oct 17, 2015

That is perfectly fine. I am already running my tests with my changes to Canopy so don't rush because of me.
Enjoy!

lefthandedgoat added a commit that referenced this pull request Oct 18, 2015
Improves performance of addition of contexts and addition of tests
@lefthandedgoat lefthandedgoat merged commit 0c5bf55 into lefthandedgoat:master Oct 18, 2015
@lefthandedgoat
Copy link
Owner

These changes are now available here:

https://www.nuget.org/packages/canopy/0.9.37

Thanks again!

@edhzsz edhzsz deleted the add_test_performance branch October 20, 2015 08:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants