ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Speed of SNDJRNE versus SNDMSG logging

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Speed of SNDJRNE versus SNDMSG logging

    I was looking for a C language sample for QJOSJRNE API and I couldn't find any. So, I used QMHSNDM API instead to log a message to a message queue instead of a journal. I was coding for the QIBM_QSO_ACCEPT exit program which I was doing in C. Anyway, I later tried to code for QJOSJRNE after I realized it isn't that complex. I am sharing the API usage code below, in case somebody needs it. I was switching to QJOSJRNE API (SNDJRNE equivalent) to test the speed of logging which can be critical in exit programs. Interestingly, both the APIs takes less than 20 microseconds to write an entry, but the QMHSNDM API (SNDMSG equivalent) takes about 100 times slower (some above 10000 microseconds) every 28th time it writes. As a result, it is at least 5 times slower than QJOSJRNE overall. Would be interesting if somebody can explain the message queue behavior (SNDMSG CLP test exhibits similar behavior).

    #include <stdlib.h>
    #include <stdio.h>
    #include <qjosjrne.h>
    #include <qusec.h>

    typedef struct {
    int numrec;
    char dummy[1];
    } JEINFO;

    int main(int argc, char **argv)
    {
    char esd[80+1];
    unsigned i;
    JEINFO jeinfo;
    Qus_EC_t err;

    jeinfo.numrec = 0;
    err.Bytes_Provided = 0;
    for(i=1; i<=10000; i++) {
    sprintf(esd,"Count=%d %60s", i, "dummy");
    QJOSJRNE("TESTJRN LIB ",
    &jeinfo, esd, strlen(esd), &err);
    }
    }
Working...
X