Performance Testing with JMeter 2.9 Book Review

Disclaimer: I was provided with a copy of the book free of charge in exchange for a review. The views expressed below are mine.

JMeter

I’ve blogged previously about my love for the simplicity of JMeter, but also acknowledged my lack of in-depth know-how and its something I should really get more to grips with. I hoped that this book would take me to the next level with JMeter, and indeed the book arrived at a very timely stage for a project I’m currently working on.

The book begins with a very good introduction into why you’d want to use JMeter (or similar tools) in the first place, and presents a scenario where the benefits of it use can be seen. It then proceeds to guide through the installation of JMeter. All good so far. Unfortunately it then starts to go into what I refer to some more advanced topics before starting to use the application for the first time. These topics deserve a mention, but perhaps appear at the wrong place in the book. However glossing over them and making a mental note for where they exist for future reference seems to suffix.

The book however did present a few nuggets of information for myself, broadly split into the following categories:

  • How to record a test plan to simulate proper use of a website
  • The session / authorisation components
  • The distributed testing model to overcome local machine performance issues
  • The ability to directly test a database connection

And for these reasons alone has proved a very worthwhile read for myself. The book also goes into detail on a number of other topics / areas, many unfortunately not relevant to me at this moment, but were interesting none the less, and just re-confirmed my initial impressions that JMeter is very powerful tool with flexibility to accommodate many situations. I’ve made a mental note of the topics covered and will no doubt refer to this book to exploit them should the need arise on future projects.

Whilst the book is very good overall, there are a couple of weaknesses that need to be highlighted. I’ve bought a number of titles in the past from PacktPub, but they’ve lacked the final polish that other publishers appear to have. This also appears apparent in this book – indeed the first step-by-step exercise that appears could be set out so much clearer with just a little thought into the layout and numbering of the steps. At one point in another exercise I found myself referring to videos on YouTube for clarity in order to overcome the problem I was facing. However, whilst this could be classed as a weakness, some (including myself) may see this as an advantage – if everything was plain sailing would we really be engaging our minds and learning?

So all-in-all, I thought a very good book. I’ve certainly learnt a lot about a very useful tool, and its encouraged me to make more use of it on current and future projects. I now feel in a position to exploit its usefulness ever further than the simple tests I had been running previously. Indeed this week I think I’ve used JMeter more times and to better effect then I have since my original JMeter blog post back in 2010.

Advertisements

Going Paperless

Last year I thought about having a new years resolution about going paperless. The length of time to write that previous sentence could probably be longer than the effort I dedicated to that task last year.

But this year I’m going to give it a shot. Not really as a resolution, but more because I used Evernote to handle my ToDo List, attempted a new way of doing things (FWIW I used my own take on GTD, I then tried to be more expressive with TSW which didn’t really work for me), which left everything in a bit of chaos. Whilst tidying Evernote out, I decided to Google around and re-read some stuff about going paperless.

So as part of my tidy up of my To Do List, I’ve decided to look at how I use Evernote and attempt to basically put everything in there from now on.

Setting Up Evernote

1. !Inbox default notebook. Everything will go here. Any email requiring more than 5 minutes work will end up for re-evaluation. Any photos I take from my phone. Any notes I take on my phone.

2. !Journal – This is my day-to-day recording of what happens each day. I start with the 3 things I want to accomplish that day (hat tip to: Getting Results the Agile Way). I also do my best to summarise what happened that day, and record my daily exercise routine.

3. Then 3 Notebook Stacks:

  • Personal Life (contains any personal documentation, car stuff, exercise articles etc…)
  • Masters Degree (with a seperate notebook for each module and my disertatation)
  • Work (seperate notebook for each project, conferences and a general folder)

4. Finally a ToDo notebook, with an individual note for the next action. I also use tags here to essentially break tasks into those relating to Home, Work or my Masters.

Getting ‘Stuff’ In

Emails

As per the GTD guide, any email to any of my accounts gets the following treatment:

  • Resolve in less than 5 minutes, now – Do It Now (and then decide whether to delete or file. If I may require in future, I email it Evernote).
  • Defer It – Send straight on to some else.
  • Don’t Do It – Delete it.
  • Do It Later – Send it to Evernote !Inbox notebook to classify and sort out.

There are 2 ways I do this. Evernote has an excellent MS Outlook Plug-In – so any work emails get a click of the plug-in and they get transferred to Evernote. Other accounts are web-based, and I simply forward them to my Evernote address (Note: create a contact called Evernote). I am considering on a couple of my less frequently used emails to try and do auto-forwarding.

Paper

Any paper I receive through the day (and to be fair, its not much), a similar process exists as email. Bin it (well, recycle it), do it or send to Evernote Inbox for later. In order to help with this, I’ve got 2 applications on my Android phone. CamScanner works really well at capturing high quality, readable images – so anything with important steps I capture via that route. It integrates nicely with Evernote.

If the quality isn’t required, then my Evernote app comes with a widget to quickly capture an image and send to Inbox.

Ideas

The Evernote widget also has a quick link to create a text note or an audio note. These notes also captured the GPS location, so (should I need to?) I’d be able to figure out where I was when capturing the note.

All That Old Paper

Well, nope. I haven’t got time really to go through it all. I also don’t own a scanner (yet!). My thoughts at this point is to capture stuff as it arrives, and then if I go hunting for anything, I’ll capture the located document at that point.

Thats It

So here we are. I’m not really sure where this will lead, but I’ll give it a shot. Probably best to review again in 6 months time for how things are going. No doubt they’ll be plenty of lessons along the way.

Soft Systems Methodology–My Understanding?

Disclaimer – I’m learning about this subject area on a module this semester so my understanding, and example given below, my be incorrect. I doing this post to gain feedback from the wider community, my tutor and fellow students.

Underlying Principle

Identify a problem. Then step back from that problem and look at the overall structure. Ask simple questions like why are doing this? What are we trying to achieve? How *should* we be doing this?

A Simple Example

So in my world of trying to make everything complex simple, leads me to bringing this subject area back to the area of football. I won’t be going in-depth so a understanding of the sport won’t be required!

Step 1 – Identify the problem (ignore the solution)

The Problem: We’re not winning football matches / trophies. Its the managers fault – sack the manager!

Step 2 – Rich Picture

Draw a rich picture showing the entire solution area – to understand connections between various stakeholders and the wider environment.

Step 3 – Step Away from the Problem:

What Are We Trying to Do: Win trophies. Be successful.

How could we do this: Ideally, we’d have the best goalkeeper, best defenders, best midfielders and best forwards in the league, if not the world. We’d also have excellent (although not necessarily the best) squad to cover any injuries and suspensions. We’d also have a very good manager to get best out of our players, and apply tactics to limit the opposition strengths and exploit their weaknesses.

Step 4 – Identify the ideal model/system to achieve this

Step Description
1 Best goalkeeper
2 Best defenders
3 Best midfielders
4 Best attackers
5 Very good squad to cover suspensions and injuries
6 Good manager to make best of our strengths and exploit other teams weaknesses

Alongside the ideal model (conceptual model) we need to consider constraints. Examples in this scenario could be money, expectations of success sooner rather than later.

We would also need to consider how to monitor progress – we could use statistics like the league table compared to this point last season, individual player stats, perhaps fitness levels.

Step 5 – Gap Analysis (Compare the Ideal model to What is Currently in Place)

Step Description Currently Have? Do Well? Further discussion
1 Best goalkeeper Yes
2 Best defenders Yes
3 Best midfielders Maybe Still best, but some getting old.
4 Best strikers No Discuss further
5 Best squad No Discuss further
6 Best Manager Yes

Step 6 – Hold Meeting to Have Discussion Points

Here we can see these likely revolve around Steps 3,4 & 5 in the model. Discussion around constraints will happen here – an immediate example would to buy 2 new forwards, but that could cost £100m – is the best investment of money, and is the money available.

A New Year on the Horizon

And I guess a look forward to some new challenges. One thing that has become apparent to myself is a lack of focus on my development of IT skills, and hence a lack of blog postings here. This has primarily been due to my Masters in Project Management taking a lot of my spare time, and then this year I also trained (and completed) for an Ironman competition.

Crossing fingers and hoping that my Masters now has 2 modules left to run and a dissertation, I’m hoping to now start thinking of turning my attention back to learning some IT skills to complement any developments next year. A practice I’ve done in previous years is to have a quick look at job boards and just search on a key term. This year I’ve chosen to look at Java. I really want to keep up with .NET but in my current environment its easier to get the latest tools for Java development. I’ll perhaps review the situation later in 2013 and see what provision would be available for keeping up to date in the Microsoft world.

Any pinching out the key words from the job descriptions a number of recurring themes seem to appear, namely:

  • Spring
  • Struts
  • Web Services
  • Automated Development and Test Driven Development
  • Hibernate / JPA
  • GlassFish / Tomcat
  • MVC
  • JMS
  • JMX
  • Oracle / MySQL
  • Multi-Threading Expertise

Some of these I know reasonably well, others I’ve only heard off in passing. I’m going to attempt to learn from scratch (to remove any bad habits) all the of the above, on a month-by-month basis. This won’t give me as a good a grounding as possible, but hopefully developing the knowledge and then finding application with come. The things I know better than others should give me a month of slight slack, whereas the other months might be a bit more intense.

The month of learning will constitute some kind of blog post – either an overarching summary of the technology, or a series of posts exploring the journey I go along.

Is there a key techonology (part of Java) that I’m really missing? Only thing on my mind is Android development which should probably get thrown into the mix at some point.

Euler Problem 5 – Weekly Update

Forgot all about this until just before the deadline, so a little bit of a rushed job. Did try to get another colleague involved, but couldn’t get them to quite cross the line.

The ProblemEuler Problem 5

2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

My Solution

Initially I had a couple of thoughts. The raw solution would be to have a for loop, simply test the remainder of the division from 1 to 20.. until the right number was found. This could be coded long handed with numerous indented if… statements for each of the numbers 1..20. Then a while loop would have presented a better way of avoiding the nested loops. If the counter got to 0 for the while loop, then I’d found my number.

My next consideration was to think about what numbers wouldn’t need to be tested if bigger numbers succeeded, e.g anything divisible by 20 would also be divisible by 2 etc… This led me to a path to stop my calculations when hitting 8 as the counter.

Finally, the for loop didn’t need to go through all the numbers. It could start at 20, and then increment by 20 every time.

To test any efficiency gains, rather than using the default output from NetBeans I also logged the in milliseconds before starting and upon completion. Interestingly (and I can’t explain why), I took slightly longer to stop dividing at 8 rather than just continue through checking the lower numbers. When I say slower, only by 1 millisecond or so.

And so my final solution is as below, and takes approximately 70 milliseconds to complete.

boolean found = false;
int sum = 0;

for (int i = 20; !found; i = i + 20) {
   int starting = 19;
   boolean breakOut = false;

   while (!found && !breakOut) {
      if ((i % starting) == 0) {
         starting--;

         if (starting == 0) {
            sum = i;
            found = true;
         }
      } else {
         breakOut = true;
      }
   }
}

Euler Problem 4

So continuing with the series of solving Euler presented problems, this shows Problem 4. Interesting I’ve teamed up with a former colleague on Twitter, @am_doherty, we’ve decided to tackle 1 a week. We’ll both post our solutions on a Friday, at about 3pm. It’ll be interesting to see different solutions that we come up with.

I chose Problem 4 this week, @am_doherty will choose the problem next week.

Euler Problem 4

A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

My Solution

At first I thought this solution would be incredibly slow, but after running it, it completes in less than a second and so seems good enough.

The main method is as follows:

int max = 0;
int param1 = 0;
int param2 = 0;
int jMin = 99;

for (int i = 999; i > 99; i--) {
  for (int j = 999; j > jMin; j--) {
    String result = Integer.toString(i * j);
    String reversed = reverseStr(result);

    if (result.equals(reversed)) {
      if (i * j > max) {
        param1 = i;
        param2 = j;
        jMin = j;
        max = i * j;
        break;
      }
    }
  }
}

System.out.println("param1 = " + param1 + ", param2 = " + param2 + ", max = " + max);

I added in a few extra parameters to reduce the loop mechanism and whilst I think these made the program a little faster, the program still executed in under a second without them.

The reverseStr method is as follows. I’m certain there may be a faster way of doing this, but with the small strings involved it seemed good enough:

public static String reverseStr(String orgStr) {
  StringBuilder reverseStr = new StringBuilder();
  for (int i = orgStr.length(); i > 0; i--) {
    reverseStr.append(orgStr.charAt(i - 1));
  }

  return reverseStr.toString();
}

Euler Problem 3

This was the 1st problem that caused me a little bit of thinking time, and hence the idea to blog.

Euler Problem 3

The prime factors of 13195 are 5, 7, 13 and 29.

What is the largest prime factor of the number 600851475143 ?

Solution / Thoughts

My 1st thought which I knew would clearly take far too long was to loop from i = 3 to 600851475143. This posed 2 problems – (a) looping for that long would take forever, and also (b) the largest prime factor was likely to be found long before the large number involved. Another thought was to loop backwards, but again this wouldn’t overcome reason (b).

The loop was speeded up slightly by incrementing by 2 rather than the traditional 1 in a for…loop, but that really didn’t do anything to overcome the problems already identified.

My way of solving it still relied on the loop thought, but worked with the idea of finding the correlating value for the earlier successful divisions. So my final implementation was:

        long number = 600851475143L;
        
        for (long i = 3; i < number; i = i + 2) {
            if ((number % i) == 0) {
                long temp = number / i;
                if (isPrime(temp)) {
                    System.out.println(temp);
                    break;
                }
            }
        }

* There are plenty of isPrime() sample methods available on the Internet.

Answer: 6857