Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

For your complicated algorithms, how do you measure its performance?

Let's just assume for now that you have narrowed down where the typical bottlenecks in your app are. For all you know, it might be the batch process you run to reindex your tables; it could be the SQL queries that runs over your effective-dated trees; it could be the XML marshalling of a few hundred composite objects. In other words, you might have something like this:

public Result takeAnAnnoyingLongTime(Input in) {
   // impl of above
}

Unfortunately, even after you've identified your bottleneck, all you can do is chip away at it. No simple solution is available.

How do you measure the performance of your bottleneck so that you know your fixes are headed in the right direction?

like image 995
Alan Avatar asked Dec 14 '22 06:12

Alan


1 Answers

Two points:

  1. Beware of the infamous "optimizing the idle loop" problem. (E.g. see the optimization story under the heading "Porsche-in-the-parking-lot".) That is, just because a routine is taking a significant amount of time (as shown by your profiling), don't assume that it's responsible for slow performance as perceived by the user.

  2. The biggest performance gains often come not from that clever tweak or optimization to the implementation of the algorithm, but from realising that there's a better algorithm altogether. Some improvements are relatively obvious, while others require more detailed analysis of the algorithms, and possibly a major change to the data structures involved. This may include trading off processor time for I/O time, in which case you need to make sure that you're not optimizing only one of those measures.

Bringing it back to the question asked, make sure that whatever you're measuring represents what the user actually experiences, otherwise your efforts could be a complete waste of time.

like image 94
TimB Avatar answered Dec 15 '22 20:12

TimB