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

Solution #80

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open

Solution #80

wants to merge 6 commits into from

Conversation

dmitryjum
Copy link

  1. Ruby solution:
    I've created 3 types of AwardsMananger class for benchmarking my ideas mostly. You can see that one (my favorite one) instantiates just one object of AwardsManager, accepts an array of awards as an argument and mutates each of them in the loop of its instance method. The second one instantiates a SingleAwardManager object per every award in an external loop and then mutates it (I expect it to be the least performant solution). And the third one doesn't instantiate NoInstanceAwardManager class at all, but mutates it using its class methods.
    I personally expected the last one to win the competition. And it does most of the times:
All awards update:   0.319682   0.013307   0.332989 (  0.333321)
single instance award update:   0.568429   0.001684   0.570113 (  0.570984)
no manager instantiation award update:   0.318844   0.000713   0.319557 (  0.319983)

But if you run the benchmark a number of times you can find it loose to my favorite solution that accepts an array of awards:

All awards update:   0.322307   0.012791   0.335098 (  0.335346)
single instance award update:   0.547072   0.001719   0.548791 (  0.549390)
no manager instantiation award update:   0.334916   0.001093   0.336009 (  0.337913)
  1. Python solution implementation resembles my preferred Ruby AwardsManager implementation.

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.

1 participant