home

# Performance Testing Tip: Start From The End

19 Jun 2008

Often performance testing starts with a statement like “we need to test the performance of X”. This statement is often devoid of any details on how to do such a thing or what you hope to discover.

### Start from the end

My simple tip is to start from the end. The first thing you should do is to design the report that you want when the effort is complete.

Any good performance report has graphs, so draw them. Label the x and y axes, figure out what each series represents, label the units. The x axis (and series) tells you what you want to vary. The y axis tells you what you want to measure. Anything not on the graph should be fixed. You must determine concrete answers for each fixed value.

Sometimes you’ll discover that one of the fixed values is really interesting and it would be great to explore what happens when that value varies. Great! Draw another graph and put that variable on the x axis. Repeat.

### Let’s try it

Let’s try a concrete example: I need to test the performance of multi-threaded Maps. (See how vague and useless that goal is?) Instead let’s focus on what graph we might want out of the answer.

Most performance graphs are going to have either response time (latency) or throughput as the y axis measurement. Let’s say throughput. We want to test multi-threaded performance, so we probably want to know how throughput changes as the number of threads changes. That’s our x axis – # of threads. Pick some x axis hash marks – those tell you concrete values to test with. Should they go up linearly, or a factor?

Throughput is measured in “actions per time”. What actions is the test performing? Often it’s useful to shove another dimension into the graph by varying something else and drawing one series per each discrete value in the extra dimension. In this case, it’s probably useful to vary what kind of actions the test is performing. I’ll make a big leap and suggest that a mixture of reads and writes is probably interesting. So we should pick some discrete mixes to test and each one becomes a series (draw the legend).

So what’s left? Well, we don’t know what kind of Map we’re testing. Let’s say we’re going to test ConcurrentHashMap. And we need to determine the size of the initial map, what kinds of keys and values should be used, etc.