You are currently viewing Refactoring nightmare Entity Framework query with performance in mind – Part III

Refactoring nightmare Entity Framework query with performance in mind – Part III

One of key problem solving methodology, PDCA (Deming circle), distinguishes 4 separate stages one should do in order to approach any problem:

  • Plan – identify what the problem is and plan best way to solve it
  • Do – implement your solution trialally
  • Check – inspect, whether your solution brings better results
  • Act – if results are better, implement your solution and make it new standard. If not, recreate the cycle for another potential solution
PDCA cycle. Fot: Wikipedia

At this point first two points are ticked already, what’s left is to check if the implemented solution improves the loading time or not.

Designing tests

Both original and improved queries are contained in ASP.NET web api get methods. To test their processing time, I used Postman’s collection runner to call both methods in a loop for iterative page numbers:

In the red rectangle there is each request’s processing time. It’s apparent that proposed solution is many times faster each time. Here’s the summary:

Trial no GetProcessesOld [s] GetProcesses [s] Change [s] Change [%]
113,6 2,311,383,1
213,5211,585,2
313,32,111,284,2
413,62,111,584,6
513,72,111,684,7
Average 13,5 2,1 11,4 84,3
Requests’ processing times in seconds

Please note that I ran more iteration of the test but each time results were pretty much equal.

Wrap up

To end this a bit too long case study, the implemented solution proved to be both clearer and faster than the initial query. Thanks to this, users spend less time wathching loading screen and the application UX is definitely better 😉

Dodaj komentarz