Thursday, November 22, 2012

Run Time Settings:

Run Time Settings:
General
Run Logic
Pacing
Log
Think Time
Additional attributes
Miscellaneous
You select runtime settings that are appropriate for what you are trying to achieve with your test, but the funny thing is that there are actually a small list of settings that are usually appropriate for most situations.
Run Logic
Whenever I am using a Vuser type that allows multiple actions in a single script, I will create a separate action for each business process and put appropriate percentage weightings on each action. It is very unusual to have to do anything more complicated than this. I don’t usually use the “sequential” option or create blocks unless I need to have fractional percentage weightings for a business process –
·         Percentages must be integer values, so to run a business process 0.1% of the time you could create a block that runs 1% of the time, and put an action in the block that runs 10% of the time.
It’s also rare to set a script in a scenario to run for a specified number of iterations (mostly done by time or set to run indefinitely). Generally “number of iterations” is only used when running the script in VuGen.
Pacing
  • “As soon as the previous iteration ends” is used when running in VuGen or when loading/verifying data. Do not use this for load testing
  • I have never seen the point of the “After the previous iteration ends” option. Why would you want to run an unknown number of transactions per hour against the system?
  • Don’t use the “At fixed intervals”. If something causes your users to become “in step”, they will tend to stay that way and continue to all hit the server at the same time.
  • “At random intervals” is definitely the way to go. Obviously for your users to create a certain number of orders per hour the iteration time must average to 3600/num iterations in an hour. Do not make the lower boundary value any bigger than the maximum time it takes to complete the business process, or you will end up creating less transactions per hour than you intend to.
Log
  • Logging creates additional overhead on your load generators, and can create huge log files.
  • I log absolutely everything when debugging in VuGen.
  • When running the script as part of a scenario, I leave extended logging on but change the logging to “Send messages only when an error occurs”. This gives a little more information than turning logging off entirely, and won’t create any additional overhead while everything is running smoothly (and if the system is not running smoothly you are going to need to stop the test and investigate anyway). 
Think Time
  • Just like the pacing setting, I think that it is a good idea to put some randomness in your think times.
  • I use a random percentage of 50-150% of recorded think times.
  • Use “Ignore think time” if you are debugging in VuGen or if you are loading/verifying data.
Additional attributes
  • This option is ignored by most people. It is used to create a parameter with a given value without having to edit the script (as runtime settings can be overridden in the Controller).
  • In the screenshot I have created a parameter of ServerName with the address of the test envioronment. If you were testing in more than one test environment at a time, this would make save some time.
Miscellaneous
  • Continue on error is generally only going to be used if you have written code to do something when you encounter an error. Usually the default behaviour of ending the current iteration and then starting the next one is sufficient). I don’t advise anyone to try to write a script that handles errors in the same way as a real user because it will create a lot of additional work for very little benefit, but doing something simple like writing some useful information to the logs and then calling lr_exit(LR_EXIT_ACTION_AND_CONTINUE , LR_FAIL) can be useful.
  • “Fail open transactions on lr_error_message” should always be ticked. If you are raising an error, you should fail the transaction step that you are performing.
  • “Generate snapshot on error” is useful. If it is a web script, any error messages should be added to your content check rules.
  • Run your virtual user as a thread unless you have code that is not threadsafe or there is some other reason to run your virtual users as a process. The overall memory footprint on your load generators will be higher if you run as a process.
  • I never use the “Define each action as a transaction” option. If I want a transaction in my script I will add it myself with lr_start_transaction.
  • I never use “Define each step as a transaction” either. If it is a web script, I can use the transaction breakdown graph to get this information, otherwise I will add the transactions myself.
Network
  • Not all vuser types have this option available.
  • Most of the time my virtual users will use the maximum bandwidth.
  • If I want to emulate users with bandwidth constraints, I will do this in a separate scenario.
  • Google calculator is handy to calculate bitrates if your bitrate is not available from the drop-down list e.g./ “256 Kbps in bps
All of the following settings only apply to web-based scripts. Each vuser type will have its own runtime setting options. It is important to know what they mean and how they will influence your
test results before running any tests that you plan to report on.
Browser:
  • Some people get confused by the User-Agent (browser to be emulated) setting. If 90% of your users use Internet Explorer 6.0 and the rest use Firefox 1.5, you don’t have to change the runtime settings for your users to match this. All it changes is the string that is sent in the “User-Agent” field of your HTTP requests. This is completely pointless unless your application has been written to serve different content to different browsers based on the User-Agent field.
  • TODO 
Proxy :
  • Generally people won’t be using your web applications through your proxy server, so it shouldn’t be part of your test either.
  • If you start getting errors that are due a proxy server rather than the system under test, it will just confuse the people who have to fix the problem.
  • A proxy server will also make IP-based load balancing ineffective.
  • If it’s an intranet application and everyone will be using the application through the company’s proxy, then the proxy server should be explicity declared to be in scope for your load test. You should make sure that you have an identical proxy server for your test environment, or that you have permission to be generating load on a piece of Production infrastructure.
Preferences
  • TODO
  • These settings are default values specified by Mercury, rather than being inherited from the web browser that is installed on your workstation. Generally you will not need to change them, but be aware that they are here.
Download Filters:
  • Download filters are a quick way of preventing your scripts from downloading content from certain URLs or hosts/domains.
  • I generally use this feature when the web application in the test environment contains third-party images used for tracking website usage (e.g. images from Webtrends or Red Sheriff etc).
  • I think it is better to specify which hosts your script is allowed connect to, rather than which hosts your script can’t connect to (because it’s easy to miss one accidentally, or the application may change and refer to a new third-party domain).
  • Use web_add_auto_filter if you want to specify this in your script rather than your runtime settings.

Configuration
  • I have talked about Content Check rules before; I think that if you aren’t using them already, then you are not getting the most out of the LoadRunner feature-set.

Thursday, July 19, 2012

C concepts


A pointer is a special kind of variable. Pointers are designed for storing memory address i.e. the address of another variable. Declaring a pointer is the same as declaring a normal variable except you stick an asterisk '*' in front of the variables identifier.
·         There are two new operators you will need to know to work with pointers. The "address of" operator '&' and the "dereferencing" operator '*'. Both are prefix unary operators.
·         When you place an ampersand in front of a variable you will get it's address, this can be stored in a pointer vairable.
·         When you place an asterisk in front of a pointer you will get the value at the memory address pointed to.

Arrays

For every type T, except void and function types, there exist the types “array of N elements of type T”.
An array is a collection of values, all of the same type, stored contiguously in memory. An array of size N is indexed by integers from 0 up to and including N-1.
For example:
int cat[10];
Arrays can be initialized with a compound initializer, but not assigned. Arrays are passed to functions by passing a pointer to the first element.

Pointer types

For every type T there exists a type “pointer to T”.
Variables can be declared as being pointers to values of various types, by means of the * type declarator. To declare a variable as a pointer, precede its name with an asterisk.
char *square;
long *circle;

C has a concept of 'data types' which are used to define a variable before its use. The definition of a variable will assign storage for the variable and define the type of data that will be held in the location.
The value of a variable can be changed any time.
C has the following basic built-in datatypes.
  • int
  • float
  • double
  • char
Please note that there is not a boolean data type. C does not have the traditional view about logical comparison, but thats another story.
int - data type
int is used to define integer numbers.
    {
        int Count;
        Count = 5;
    }
float - data type
float is used to define floating point numbers.

    {
        float Miles;
        Miles = 5.6;
    }
double - data type
double is used to define BIG floating point numbers. It reserves twice the storage for the number. On PCs this is likely to be 8 bytes.

    {
        double Atoms;
        Atoms = 2500000;
    }
char - data type
char defines characters.
    {
        char Letter;
        Letter = 'x';
    }
Modifiers
The data types explained above have the following modifiers.
  • short
  • long
  • signed
  • unsigned
The modifiers define the amount of storage allocated to the variable. The amount of storage allocated is not cast in stone. ANSI has the following rules:

        short int <=    int <= long int
            float <= double <= long double
What this means is that a 'short int' should assign less than or the same amount of storage as an 'int' and the 'int' should be less or the same bytes than a 'long int'. What this means in the real world is:
                 Type Bytes             Range
---------------------------------------------------------------------
            short int  2          -32,768 -> +32,767          (32kb)
   unsigned short int  2                0 -> +65,535          (64Kb)
         unsigned int  4                0 -> +4,294,967,295   ( 4Gb)
                  int  4   -2,147,483,648 -> +2,147,483,647   ( 2Gb)
             long int  4   -2,147,483,648 -> +2,147,483,647   ( 2Gb)
          signed char  1             -128 -> +127
        unsigned char  1                0 -> +255
                float  4
               double  8 
          long double 12
These figures only apply to todays generation of PCs. Mainframes and midrange machines could use different figures, but would still comply with the rule above.
You can find out how much storage is allocated to a data type by using the sizeof operator discussed in Operator Types Session.
Here is an example to check size of memory taken by various datatypes.
int
main()
{
  printf("sizeof(char) == %d\n", sizeof(char));
  printf("sizeof(short) == %d\n", sizeof(short));
  printf("sizeof(int) == %d\n", sizeof(int));
  printf("sizeof(long) == %d\n", sizeof(long));
  printf("sizeof(float) == %d\n", sizeof(float));
  printf("sizeof(double) == %d\n", sizeof(double));
  printf("sizeof(long double) == %d\n", sizeof(long double));
  printf("sizeof(long long) == %d\n", sizeof(long long));

  return 0;
}
Qualifiers
A type qualifier is used to refine the declaration of a variable, a function, and parameters, by specifying whether:
  • The value of a variable can be changed.
  • The value of a variable must always be read from memory rather than from a register
Standard C language recognizes the following two qualifiers:
  • const
  • volatile
The const qualifier is used to tell C that the variable value can not change after initialisation.
const float pi=3.14159;
Now pi cannot be changed at a later time within the program.
Another way to define constants is with the #define preprocessor which has the advantage that it does not use any storage
The volatile qualifier declares a data type that can have its value changed in ways outside the control or detection of the compiler (such as a variable updated by the system clock or by another program). This prevents the compiler from optimizing code referring to the object by storing the object's value in a register and re-reading it from there, rather than from memory, where it may have changed. You will use this qualifier once you will become expert in "C". So for now just proceed.
What are Arrays:
We have seen all baisc data types. In C language it is possible to make arrays whose elements are basic types. Thus we can make an array of 10 integers with the declaration.
int x[10];
The square brackets mean subscripting; parentheses are used only for function references. Array indexes begin at zero, so the elements of x are:
Thus Array are special type of variables which can be used to store multiple values of same data type. Those values are stored and accessed using subscript or index.
Arrays occupy consecutive memory slots in the computer's memory.
x[0], x[1], x[2], ..., x[9]
If an array has n elements, the largest subscript is n-1.
Multiple-dimension arrays are provided. The declaration and use look like:
      int name[10] [20];
      n = name[i+j] [1] + name[k] [2];
Subscripts can be arbitrary integer expressions. Multi-dimension arrays are stored by row so the rightmost subscript varies fastest. In above example name has 10 rows and 20 columns.
Same way, arrays can be defined for any data type. Text is usually kept as an array of characters. By convention in C, the last character in a character array should be a `\0' because most programs that manipulate character arrays expect it. For example, printf uses the `\0' to detect the end of a character array when printing it out with a `%s'.
Here is a program which reads a line, stores it in a buffer, and prints its length (excluding the newline at the end).
       main( ) {
               int n, c;
               char line[100];
               n = 0;
               while( (c=getchar( )) != '\n' ) {
                       if( n < 100 )
                               line[n] = c;
                       n++;
               }
               printf("length = %d\n", n);
       }
Array Initialization
  • As with other declarations, array declarations can include an optional initialization
  • Scalar variables are initialized with a single value
  • Arrays are initialized with a list of values
  • The list is enclosed in curly braces
int array [8] = {2, 4, 6, 8, 10, 12, 14, 16};
The number of initializers cannot be more than the number of elements in the array but it can be less in which case, the remaining elements are initialized to 0.if you like, the array size can be inferred from the number of initializers by leaving the square brackets empty so these are identical declarations:
int array1 [8] = {2, 4, 6, 8, 10, 12, 14, 16};
int array2 [] = {2, 4, 6, 8, 10, 12, 14, 16};
An array of characters ie string can be initialized as follows:
char string[10] = "Hello";

About ShankarChinn

My photo
Bangalor, karnataka, India
I created this Blog to store knowledge and help other with the same. URL:http://shankarchinn.blogspot.in/ By : Shankar Nath.Chokkam