June 27, 2016

Sorting objects - working with "Java Comparator"

Today I want to show you how to sort objects by one or more properties. There are a lot of possibilities how to do that.
There are two interfaces in Java which help you to sort a list. There is the Comparator interface and the Comparable interface. So how do you decide which one to use?

API interface definition Comparable<T>:
"This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering, and the class's compareTo method is referred to as its natural comparison method."  [1]

Simply put, if you implement the Comparable interface in a class, the class instance is able to compare itself to another object. So you can just use Collections.sort(List<T> list); and you will get a sorted list.

June 22, 2016

Performance Testing with Gatling, Part 1

This is the first part of a two-part series covering the theory on performance
testing. The next part will showcase a practical example using Gatling, an “open-source load
testing framework based on Scala, Akka and Netty”.

Introduction

Testing system performance can be done on multiple levels. Last time, we covered micro
benchmarking with JMH. Whereas micro benchmarking deals with optimization of code and algorithms, testing system performance ensures that an entire system meets the required metrics such as throughput and response times.