Run multiple Gatling simulations with Maven

By , November 28, 2014

Gatling is nice load testing framework that uses Scala, Akka and Netty. It’s so much better than JMeter. It’s pretty easy to get started with scenarios written in a nice Scala DSL and it produces useful reports too. It also has a Maven plugin so you can incorporate continuous performance testing in your builds.

The trouble is if you list multiple scenarios in a simulation they will all run concurrently which is probably not what you want. You need to split your tests into separate Simulation classes and run them sequentially. The plugin documentation briefly describes a way of doing this using executions but the example is a little light.

Here’s a Maven profile that when activated will run your simulations sequentially. Execute the tests with mvn test -Pperformance.

Generating random mobile numbers with Scala

By , September 22, 2014

Sometimes in testing we need to generate random data. When it comes to generating mobile numbers it would be helpful if we could be sure they aren’t allocated to a real person, just in case we accidentally send 1000 text messages to random phone numbers. Luckily Ofcom has reserved ranges of numbers for dramatic use that are guaranteed not to be allocated to providers.

Here’s a little random UK mobile number generator wrapped in an infinite-length iterator:

Bonus random MAC address generator
Sometimes we need MAC addresses too. This will generate strings that look like MAC addresses (6 groups of hex digits) but aren’t really. Good enough for my purposes:

2013 Track Days

By , December 14, 2013

Given the arrival of Jr in August my track time was rather limited this year but I still managed to do another level of CSS and a couple of lovely sunny days at Snetterton; one of my new favourite tracks.

The year started with CSS level 3 in the snow at Silverstone. God it was cold, but CSS is always great.

Then the track day at Snetterton at the beginning of May.

And quickly back to Snetterton for another go at the end of May.

I also finally managed to get my GoPro on track. Here’s a video from the track day:

Calculating distance with Scala’s foldLeft

By , October 17, 2013

I wanted a way to calculate the total distance of a GPS track. A track is basically just a list of lat,long pairs – represented in Scala by the following:

One way to do this would be to iterate over the sequence, calculating the distance between points (using the haversine formula) and updating the sum in a variable but since this is Scala we can do it in a more functional way.

According to the Scaladoc, foldLeft “Applies a binary operator to a start value and all elements of this list, going left to right.” The signature looks like this for List[A] (a List of type A):

The first parameter z is of type B, so it can be different from the list type. The second parameter is a function that takes a B and an A (one of the list items) and produces a B.

The neat bit is this function iterates over the list and passes in each item to function f as the value of A. For the first item, z is passed in to f as the value of B. For each subsequent item the result of the previous call to f is used.

The usual example you will find is to sum a list of integers or something similar, like this:

This will return the sum of all the items items in a list.

My use-case was slightly different. My list consisted of tuples and I needed to apply a function to each pair of tuples in the list and accumulate the sum of those results. This meant I needed to keep track of both the current element and the previous one during the folding.

It was Matt Malone’s page of lots and lots of foldLeft examples that put me on the right track, specifically his example for Average which showed how to use a tuple as an accumulator. Here’s how I did it:

As I said, points is just a sequence of lat,long pairs, eg:

We first split the list into head and tail and use head and 0.0 as initial values. The folding function then produces a Tuple2[(Double, Double), Double]. The first item of the resultant tuple is the current list element and the second item is the sum of the current total and the result of the haversineDistance function (which itself takes as input the previous element and the current element).

The pattern matching is used to handle the case of an empty list.

Phew! This one line took me a while to figure out but it packs a lot of work into just a single line of code and shows how powerful Scala can be. Experimenting with the REPL was invaluable here.

For completeness, here’s the haversine function which calculates the distance between two points on the Earth (3958.761 is the mean radius of the Earth in miles):

MotoCal: Personalised motor racing calendars

By , March 2, 2013

IMG_9335I like just about any kind of motor sport. If it has wheels and an engine then I’m probably interested in watching it drive round in circles for a couple of hours. But there are a few race series I follow closely and try to watch on TV whenever I can: Formula One, MotoGP, Superbike.

Wouldn’t it be good, I thought, if I could subscribe to a single calendar feed that showed all the races I was interested in (and none of the ones I wasn’t).

So I built

I’ve put all the hard work into collecting all the qualifying and race times so you don’t have to. Just click on each race series you want in your calendar and it will generate a URL that you can stick into your calendar application (Google, Apple, Outlook) and you  will get  a synchronised calendar that is automatically kept up to date.

You can currently subscribe to any and all of the following:

It’s pretty easy to add more calendars so leave a comment if you would like to see any other series.

Things I can see from my window

By , December 15, 2012

It’s nice not living in a basement anymore. Living on the river means we get quite a good angle of view. Here’s some stuff I can see.

Lots Road Power Station

Not the four-stack one down the river but the two-chimney version that used to power the London Underground. In fact, Lots Road used to have four chimneys too  but by the late 70’s it had been reduced to two. Built in 1905, twenty-four years before Battersea Power Station, it was claimed to be the largest power station ever built with a capacity of 50,000 kW.


Stamford Bridge

Just peeking over the tops of the buildings is the home ground of Chelsea Football Club. Opened in 1877 it was first used for athletics until Chelsea took over in 1905.


Empress State Building

Built in 1961, this building is occupied by the Metropolitan Police Service. A building called the Empress Hall used to stand on the site. It has a private revolving bar at the top and in the evening it catches the setting sunlight on one of its three curved sides beautifully.


Queen’s Tower

The 87 m tall Queen’s Tower is in the campus of Imperial College London at South Kensington. It is the sole remaining part of the Imperial Institute. When the Imperial Institute was demolished, Victorian architecture was not fashionable and the tower was only saved by a campaign led by John Betjeman. The tower houses ten bells donated in 1892 by Mrs Elizabeth M. Millar of Melbourne, Australia.


The Imperial Crown

Designed by Aston Webb, after winning a competition in 1891 to extend the museum, the tower above the main entrance to the Victoria and Albert Museum has an open crown topped by a statue of Fame. Webb wanted to “mark the character as a great national building.”

Natural History Museum

I love the architecture of this building by Alfred Waterhouse and I can just see the two towers that frame the entrance.


Crosby Hall

This is a strange building. According to Wikipedia: Part of the building’s architectural features are from the Great Hall, which is the only surviving part of the mansion of Crosby Hall, Bishopsgate which was built in 1466 by the wool merchant John Crosby. Crosby rented it to Richard Duke of Gloucester who used it as his London home. It was used as the setting for a scene in William Shakespeare’s Richard III. In the reign of Henry VIII it belonged to Antonio Bonvisi.

Following a fire in 1672 only the Great Hall and Parlour wing of the mansion survived, it then became a Presbyterian Meeting House and then a warehouse with an inserted floor.

In 1910 it was threatened with demolition and then moved brick by brick to its present site and the rest of the building by Walter Godfrey constructed around it. The move was paid for by the Bank of India who had purchased the Bishopsgate site to build offices. Godfrey also added the north wing in 1925-6 as a women’s university hall of residence.


Battersea Bridge

Not as flashy as Albert or Chelsea Bridge, Battersea Bridge used to be the last wooden bridge over the River Thames until the old bridge was demolished in 1885 and replaced by the current one designed by Sir Joseph Bazalgette. Despite it being the narrowest road bridge over the Thames, trams used to run over it until 1950 and due to it being on a bend in the river it is a hazard to navigation being subject to numerous collisions in its history.


Winter Wonderland

Being Christmas, I can also see the Giant Observation Wheel and the Power Tower in Hyde Park.


2012 Track Days

By , November 22, 2012

2012 was a pretty busy year for me!
Started off with CSS Level 1 in March:


Then the forum trackday at Cadwell on a chilly April day:

Back to Silverstone for a damp CSS Level 2 in May (still waiting for the weather to warm up):


Then Brands GP with TripleJimmy:


Unfortunately this also involved a little off-track excursion. :-(


No pics from Rockingham in July with buzz675 but Bedford in July I felt was my most successful day. Lovely and warm and also ran into Farebro doing his licence:


Back up to Cadwell in August (finally summer!):


And finished the season at Brands Indy:


Looking forward to finishing the CSS and another good year of track days in 2013!

Adelaide to Phillip Island (and back again)

By , November 17, 2012

A few weeks ago I went back to Oz and hired a bike in Adelaide to ride across to Phillip Island for the MotoGP. Unfortunately, unless I wanted a cruiser, Adelaide literally had a choice of one half-decent bike so I loaded up the Kriegas and headed off on the Yamaha FZ600 with Mark on his Aprilia.

We took the quick route across; heading straight down the Western Highway stopping off in Ararat for the night. It had been a while since I’d been that way. Man they build some long straight roads in Australia! I had also come down with some kind of man-flu so was feeling pretty rough and not in the best condition for a long distance ride. A lamington at Kaniva helped.

Next day, instead of going through Melbourne we dropped down to Geelong and caught the ferry over to the Mornington Peninsula. While waiting for the ferry we chatted to a guy who had ridden his Blackbird from Western Australia!

It was still another good couple of hours to the Island so it was getting late in the day when we arrived. The sky was also looking very threatening and we struggled with some epic winds but no rain so far!

This was the first time I’d been to Phillip Island and I have to say what a fantastic track! Such a beautiful location by the sea and it looks like it would be awesome to ride. It’s definitely one of the great circuits of the world. We had seats at Lukey Heights and so could see most of the track and also had a lovely backdrop of Bass Straight.

Unfortunately the weather was a bit rubbish. Bloody cold with the occasional shower most days but race day was alright. Stoner absolutely dominated the race and there was an Aussie on the podium for all three races so the home crowd was happy.

On the way back we took the Great Ocean Road. All I can say is wow! This really was epic! I wished I had my Daytona. Without doubt it’s one of the great biking roads of the world. It starts off snaking around the mountains by the sea. Really twisty with dramatic views and you can’t think it can get any better. But then at Apollo Bay it heads off into the Great Otway National Park with fast sweeping bends shooting through the forest. My God it was amazing. GoPro footage to come!

We stayed the night at Port Campbell which is near the 12 Apostles.

The next day it was back onto boring South Australian roads and the long straight slog back home. We made sure to stop at the Big Lobster though. :-)

More pictures from the race here.

Westbound commute 1

By , October 18, 2012

The public transport options for getting to work are so bad the pushbike is really the best option. I’m trying to find the best route.

This wasn’t too bad although the traffic is pretty nasty in the Farringdon St/Fleet St/Strand area and the shortcut from Clerkenwell Rd to Farringdon Rd didn’t really work because of all the Crossrail construction work. I think next time I’ll cut out the Strand and go via Charing Cross Rd.

  • Distance: 6.38 mi
  • Duration: 38 mins
  • Avg speed: 9.90 mph

GPXpress – a WordPress plugin for displaying GPS tracks

By , September 15, 2012

When I was in the Lake District the other week I tried out an iPhone app by Felix Lamouroux called Trails. It’s a really great app that you can use to record where you go on hiking trips, bike rides, etc. One cool feature of the app is the ability to export your tracks as a GPX file and I wanted to be able to show this on a map on my blog.

So this afternoon, with the help of Leaflet and Open MapQuest, I made a little WordPress plugin to do just that.

Here is the result; my walk round Wastwater:


To install the plugin:

  1. Download the ZIP file from GitHub and drop the contents in the wp-content/plugins/ directory of your WordPress installation.
  2. Activate the plugin from Plugins page.
  3. Go to the plugin settings page and choose the colour of your tracks. This may be any valid HTML colour code (default is ‘red’).

To add a map to a post:

  1. Insert the [gpxpress] shortcode into your post where you want to display the map. Use the ‘src’ parameter to specify the URL of the GPX track you want to display. Use the ‘width’ and ‘height’ parameters to give the width and height of the map in pixels (default is 600×400). Eg, [gpxpress src= width=600 height=400].

You could also use my Garmin Communicator plugin to add a button that allows people to download your track directly to their Garmin device.

Panorama Theme by Themocracy