0

I am looking for a code which can generate V4 UUID using UTC Timestamp as input.

I want use this code in my Load Runner script to pass UUID in my Load Runner request.

Appreciate if the code is provided in C++

eyllanesc
  • 235,170
  • 19
  • 170
  • 241
Perf_Er
  • 11
  • 1
  • I don't believe the standard C++ library provides UUID generation facility, but many frameworks do. Qt, for one, has a `QUuid` class. Windows has COM interface for that. – Violet Giraffe Oct 10 '16 at 10:59

3 Answers3

1

I recall using something like

int GenerateGuid()
{
    typedef struct _GUID
    {
        unsigned long Group1;
        unsigned short Group2;
        unsigned short Group3;
        unsigned char Group4[8];
    } GUID;

    GUID m_guid;
    char msgId[msgIdSize];

    lr_load_dll("ole32.dll");

    CoCreateGuid(&m_guid);

    sprintf(msgId, "%08lx-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
        m_guid.Group1, m_guid.Group2, m_guid.Group3,
        m_guid.Group4[0], m_guid.Group4[1], m_guid.Group4[2], m_guid.Group4[3],
        m_guid.Group4[4], m_guid.Group4[5], m_guid.Group4[6], m_guid.Group4[7]);

    lr_save_string(msgId, "msgId");

    return 0;
}

This is basically call of CoCreateuid function (will apply to Windows load generators only) and storing the result into msgid LoadRunner Parameter.

Actually it was the last time I used LoadRunner as as far as I remember it failed to produce required amount of large POST requests on the hardware (and I also had to work around several artificial limitations on request size) while Apache JMeter worked as a charm. Just to compare, you need just call a single function like: ${__UUID} and that's it. Check out Writing Your First JMeter Script article if interested.

Dmitri T
  • 159,985
  • 5
  • 83
  • 133
0

LoadRunner is a C virtual User, not C++

I refer you to the built-in functions web_save_timestamp_param() or lr_save_timestamp() as options for your use

James Pulley
  • 5,606
  • 1
  • 14
  • 14
0

I am using the below code to generate UUID in loadrunner independent of the OS of the Loadgenerators. Please check this link as well - How to generate Universally Unique IDentifier, UUID from LoadRunner independent of the OS

int lr_guid_gen()
{

    char GUID[40];
    int t = 0;
    char *szTemp = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx";
    char *szHex = "0123456789abcdef-";
    int nLen = strlen (szTemp);


    for (t=0; t<nLen+1; t++)
    {
        int r = rand () % 16;
        char c = ' ';   

        switch (szTemp[t])
        {
            case 'x' : { c = szHex [r]; } break;
            case 'y' : { c = szHex [r & 0x03 | 0x08]; } break;
            case '-' : { c = '-'; } break;
            case '4' : { c = '4'; } break;
        }

        GUID[t] = ( t < nLen ) ? c : 0x00;
    }

    lr_save_string(GUID,"PAR_GUID");

    return 0;
}
Barun
  • 23
  • 2
  • 7