Skip to content

fix: Change string.Format style to string interpolation #225

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

Merged
merged 18 commits into from
Jul 6, 2020

Conversation

msohailhussain
Copy link
Contributor

@msohailhussain msohailhussain commented Jun 30, 2020

Summary

  • Changed string.Format to string interpolation format. string.Format is bit expensive operatino.
  • Added thread safe support for ForcedVariation.

Test plan

  • FPS shouldn't break it.

#if NET35
private Dictionary<string, Dictionary<string, string>> ForcedVariationMap;
#else
private System.Collections.Concurrent.ConcurrentDictionary<string, Dictionary<string, string>> ForcedVariationMap;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ThreadSafe dictionary.

TODO: Add unit test

@msohailhussain msohailhussain marked this pull request as ready for review July 1, 2020 20:30
@msohailhussain msohailhussain requested a review from a team as a code owner July 1, 2020 20:30
@msohailhussain msohailhussain removed their assignment Jul 1, 2020
@msohailhussain msohailhussain changed the title Change string style to string interpolation - DO NTO REVIEW fix: Change string.Format style to string interpolation Jul 1, 2020
Copy link
Contributor

@mikeproeng37 mikeproeng37 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, are you able to profile and show some numbers along with where/how you ran it? Just curious

@msohailhussain
Copy link
Contributor Author

Sure, I will share results.

@msohailhussain
Copy link
Contributor Author

@mikeng13 I tested it separately and don't see any major difference. For more than 150K+ requests it took 0.5 seconds for this log.
string.Format(@"{0} Variation ""{1}"" is mapped to experiment ""{2}"" and user ""{3}"" in the forced variation map", Logger.DEBUG, experimentKey, variationKey, i.ToString());
and I see more or less the same time (avg 0.445 sec)
$@"{Logger.DEBUG} Variation ""{ experimentKey}"" is mapped to experiment ""{variationKey}"" and user ""{i.ToString()}"" in the forced variation map";

@mikeproeng37
Copy link
Contributor

Thanks

@mikeproeng37 mikeproeng37 merged commit d9050b9 into master Jul 6, 2020
@mikeproeng37 mikeproeng37 deleted the sohail/improveperformance branch July 6, 2020 20:11
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.

3 participants