Mastering Web Application

(Rick Simeone) #1
Chapter 11

Performance tuning – set expectations, measure, tune, and repeat


Performance tuning requires a disciplined approach where:



  • Expectations regarding performance characteristics are clearly defined,
    including measurable performance counters, alongside conditions under
    which measures are taken.

  • A current performance of a system is measured and cross-checked
    with expectations.

  • If a system is not up to the expected standards, then performance bottlenecks
    need to be identified and fixed. After a fix is performed the whole process
    of measuring needs to be repeated to prove that a fix brings system
    performance to expected levels or identify further bottlenecks.


There are two very important lessons that we can draw from the process sketched
earlier. First of all, we need to clearly set expectations and conditions under which
performance characteristics are considered and measured. Secondly, the performance
tuning is not a goal in itself, it is a process to bring the system to the point where it
behaves as expected.


AngularJS, as any other well-engineered library, was constructed within a frame of
certain boundary conditions, and those are best described by Miško Hevery, father of
AngularJS (http://stackoverflow.com/a/9693933/1418796):


So it may seem that we are slow, since dirty checking is inefficient. This is where
we need to look at real numbers rather than just have theoretical arguments, but
first let's define some constraints.

Humans are:

slow — Anything faster than 50ms is imperceptible to humans and thus can be
considered as "instant".

limited — You can't really show more than about 2000 pieces of information to a
human on a single page. Anything more than that is really bad UI, and humans
can't process this anyway.

So the real question is this: can you do 2000 comparisons in 50 ms even on slow
browsers? That means that you have 25μs per comparison. I believe this is not an
issue even on slow browsers these days.
Free download pdf