News

Open Source Troubleshooting for Java

Performance News - 12 May 2008 - 5:56pm
VisualVM is an OpenJDK project from Sun to create an all-in-one troubleshooting tool for Java applications. The tool is a combination of several existing tools and newer profiling capabilities. By Craig WickesserCraig Wickesser

Examples on LoadRunner Regular Expressions

Performance News - 1 May 2008 - 1:11am
I'm going to show and explain how to use Regular Expressions in LoadRunner.

Introduction:
The present article is a summarizing of the LoadRunner Regular Expressions challenge and its results. Also, I added code for RegExp patterns/subpatterns matching.
All LoadRunner Regular Expressions functions are shown with examples.


Outline:
  1. How to check - whether RegExp pattern matches against a text or not
  2. How to get a matched strings (RegExp patterns and subpatterns)

How to check - Whether RegExp pattern matches against a text or not

I thanks Charlie Weiblen and Tim Koopmans for the solution. I modified it slightly.
So, here it is:
  1. Download and unpack Binaries and Developer files for PCRE (Perl Compatible Regular Expressions).
    These and others files are available on Pcre for Windows page.

  2. Unzip downloaded archives into c:\pcre
  3. Сomment out the include for stdlib.h file in:
    • C:\pcre\include\pcre.h
    • C:\pcre\include\pcreposix.h
  4. In your LoadRunner script, add to globals.h:
    • #include "c:\\pcre\\include\\pcre.h"
    • #include "c:\\pcre\\include\\pcreposix.h"
  5. Add the match() function to vuser_init section:
    //////////////////////////////////////////////////////////////////////////
    /// 'match' function matches a 'pattern' against a given 'subject'
    /// It returns 1 for a match, or 0 for a non-match / error
    int match(const char *subject, const char *pattern)
    {
        int rc;            // Returned code
        regex_t re;        // Compiled regexp pattern
        
        lr_load_dll("c:\\pcre\\bin\\pcre3.dll");
        
        if (regcomp(&re, pattern, 0) != 0)
            return 0;     // Report error
        
        rc = regexec(&re, subject, 0, NULL, 0);
        regfree(&re);

        if (rc != 0)
            return 0;     // Report error
        else
            return 1;
    }
  6. Let's run sample LoadRunner script and check the result:
    As you can see, match() function works correctly. Using match() function, you can check - whether RegExp pattern matches against a text or not.

    It can be helpful, when you verify in LoadRunner that the text (RegExp pattern) matches the text on a downloaded page.

    I tested the match() function with different patterns and subject strings:
    #
    Subject string
    Patterns
    Result of
    match()
    Is correct
    result?
    1
    abcdefb(c(.*))e
    1
    Yes
    2
    abcdef
    b(z(.*))e
    0
    Yes
    3
    2008
    \\d{2,5}
    1
    Yes4
    2008
    \\d{5}
    0
    Yes5
    abc 1st of May 2008xyz
    \\d.*\\d
    1
    Yes
    Note: Since LoadRunner uses ANSI C language, please do not forget to double backslashes (\\). For example, to match any digit character (0-9), use pattern "\\d".

    match() function is simple enough. But it searches only and it cannot extract matched subpatterns from the text. For example, we have to extract the name of month from these strings:
    • "abc 1st of May 2008xyz"
    • "abc 25th of February 2031"
    • etc
    We can use the following pattern:
    • \d.+([A-Z]\w+)\s+\d{4}

    The name of month will be matches by subpattern ([A-Z]\w+). How to extract the found text? You can use matchex() function for that. Let's discuss it in details...

How to get a matched strings (RegExp patterns and subpatterns)

To get a matched (found) strings, we have to update our match() function.
That's why I created matchex() ('match' EXtended) function.
  1. Add the matchex() function to vuser_init section
    //////////////////////////////////////////////////////////////////////////
    /// 'matchex' (EXtended) function matches a 'pattern' against a given 'subject'
    /// It returns number of matches:
    ///     0 - for a non-match or error
    ///     1 and more - for successful matches
    int matchex(const char *subject, const char *pattern, int nmatch, regmatch_t *pmatch)
    {
        int rc;            // Returned code
        regex_t re;        // Compiled regexp pattern

        lr_load_dll("c:\\pcre\\bin\\pcre3.dll");

        if (regcomp(&re, pattern, 0) != 0)
            return 0;     // Report error

        rc = regexec(&re, subject, nmatch, pmatch, 0);
        pcre_free(&re);    // Release memory used for the compiled pattern

        if (rc < 0)
            return 0;     // Report error

        // Get total number of matched patterns and subpatterns
        for (rc = 0; rc < nmatch; rc++)
            if (pmatch[rc].rm_so == -1)
                break;

        return rc;
    }
  2. Let's run sample LoadRunner script and check the result:
    matchex() function returns a number of matched patterns/subpatterns and fill an array in with information about each matched substring.


    What is an information about each matched substring?

    This info contains the offset (rm_so) to the first character of each substring and the offset (rm_eo) to the first character after the end of each substring, respectively.

    Note1: The 0th element of the array relates to the entire portion of string that was matched.
    Note2: Subsequent elements of the array relate to the capturing subpatterns of the regular expression.
    Note3: Unused entries in the array have both structure members set to -1.

    Let's investigate it on out example. This is our subject string:
    The replay log shows offsets for matched substrings:
    • Action.c(7): Matched 3 patterns
    • Action.c(10): Start offset: 1, End offset: 6
    • Action.c(10): Start offset: 2, End offset: 5
    • Action.c(10): Start offset: 3, End offset: 5

    Start offset: 1 and End offset: 6 match substring "bcdef".
    Note4: End offset is the first character after the end the current substring. That's why character "g" (with index 6) is not a part of matched string.

    As I've written in Note1, "bcdef" is the entire portion of string that was matched.
    Others items from an array relate to matched subpatterns.


    What is a subpattern in Regular Expression?

    It is a part of the RegExp pattern surrounded with parenthesis - "(" and ")".

    It's easy to get out the order of subpatterns. Just look through your pattern from left to right. When you find an open parenthes, this is a start of the current subpattern.
    Subpattern can be embedded.

    So, others captured subpatterns are:
    • Start offset: 2, End offset: 5 matches substring "cde".
      Note: current subpattern is "([acqz](.*))".
    • Start offset: 3, End offset: 5 match substring "de".
      Note: current subpattern is "(.*)".

    As you can see - this is not so difficult. :)
    Regular Expressions can be very powerful and useful in LoadRunner.

Another example:

Let's practise with an example I mentioned early:
For example, we have to extract the name of month from these strings:
  • "abc 1st of May 2008xyz"
  • "abc 25th of February 2031"
  • etc
We can use the following pattern:
  • \d.+([A-Z]\w+)\s+\d{4}
The name of month will be matches by subpattern ([A-Z]\w+).

Please, see LoadRunner script, which captures and prints name of months:
Note: Pay attention that I use arr[1] to get info about substring.
As you remember, arr[0] contains info about the entire matched pattern, arr[1], arr[2], and so on contain info about matched subpattern.


Summary:
I've explained, shown and demonstrated how to use Regular Expressions (RegExp) in LoadRunner.
I hope, this knowledge will help you to create advanced LoadRunner scripts.

--
Thank you, my readers!
Dmitry Motevichnoreply@blogger.com (http://motevich.blogspot.com)

Python - RRDTool Utilities (module and scripts for RRDs)

Performance News - 29 April 2008 - 10:37am

I started a project on Google Code to create a set of Python tools to make dealing with Round Robin Databases (RRD) less painful.  Setting up RRD's can be tough if you don't know what you are doing.

anyone interested can check it out here:  rrdpy

I used it to create a simple HTTP monitoring script (included in source) to graph web response latency like this:

Multiple Dimensions of Performance Testing

Performance News - 24 April 2008 - 8:18pm
Almost all experts agree that pre-deployment "waterfall" performance testing (which, with the record/playback method, confused by many as the performance testing itself) is not enough - too little, too late. Actually it is just one very specific way of performance testing - with a full spectrum of other approaches, which are used so infrequently (at least as intentional performance testing techniques) that I don't recall finding any good classification. Thinking about it, I see several dimensions of performance testing which, although definitely correlated, probably might be considered somewhat independently - of course, just a raw idea for the moment, just an effort to order thoughts a little.(author unknown)

Roll Your Own SiteScope, a Simple Alternative

Performance News - 23 April 2008 - 3:06am

In working with SiteScope of late, I’ve found that it doesn’t always collect performance metrics the way I want to. More importantly, it can often turn a simple monitoring activity into a complex disaster. Take monitoring via JMX for example. In SiteScope, it has a rather complicated (and sometimes broken) interface when trying to communicate with a busy MBean Server. One can quite easily roll your own JMX monitor using open source tools in about 65 lines of code as I demonstrated here.

But we still all use tools like LoadRunner in these commercial 9-5 contracts right? Wouldn’t it be nice, if you could roll your own custom monitors in Ruby, Perl or whatever language you like, store that data in a simple repository, let’s say a MySQL database, and still be able to hook into those metrics from a LoadRunner Controller during test execution!?

It is possible, with one PHP file and a simple WAMP (or LAMP) installation all wrapped up in a SiteScope-like alternative.
(more…)

StickyMinds.com Weekly Column: Peeling the Performance Onion

Performance News - 21 April 2008 - 5:06am
Performance tuning is often a frustrating process, especially when you remove one bottleneck after another with little performance improvement. Danny Faught and Rex Black describe the reasons why this happens and how to avoid getting into that situation. They also discuss why you can't work on performance without also dealing with reliability and robustness.Danny R. Faught and Rex Black

Hands-off Load Testing with JMeter and Ant

Performance News - 18 April 2008 - 2:00pm
Automation expert Paul Duvall highlights in a recent post the value of earlier and continuous integration of load tests throughout the development cycle and presents simple step-by-step techniques to create a scheduled integration build that runs JMeter tests. By Alexander OlaruAlexander Olaru

Podcast: &quot;Diving into Capacity Planning&quot;

Performance News - 11 April 2008 - 1:46pm
A podcast that I did for TeamQuest Corporation, back in December, is now available. It's a somewhat unconventional take on the motivations for doing CaP, based on taking into account the apparently frustrating but otherwise very realistic perspective of management. During the podcast, I refer to the CMG Keynote given by Jerred Ruble (CEO of TeamQuest Corp.) Here is the abstract of his presentation entitled, "Is Capacity Planning Still Relevant?" (click to enlarge)

Simple registration required to download the 25 MB mp3 file. This podcast also gives you an idea of some the things we will be treating in the Guerrilla Boot Camp class on April 28-29, 2008.
Syndicate content