ApacheBench

 view release on metacpan or  search on metacpan

src/ApacheBench.xs  view on Meta::CPAN

                if (SvTRUE(tmpsv))
                    registry->keepalive[j] = 1;
                else
                    registry->keepalive[j] = 0;
            else
                registry->keepalive[j] = def_keepalive;
            if (AB_DEBUG_XS) printf("AB_DEBUG: run %d setup2 - stage 6.3, j=%d\n", k, j);
        }

        /*If the number of keepalive strings is less than
          that of urls, then assign object's default keepalive value */
        for (j = i; j < registry->position[k+1]; j++)
            registry->keepalive[j] = def_keepalive;


        if (AB_DEBUG_XS) printf("AB_DEBUG: run %d setup2 - stage 7\n", k);

        /* find smaller of url_tlimits array length and urls array length */
        tmpav = (AV *) SvRV(url_tlimits);
        i = ap_min(registry->position[k+1],
                   registry->position[k] + av_len(tmpav) + 1);

        if (AB_DEBUG_XS) printf("AB_DEBUG: run %d setup2 - stage 7.1\n", k);

        /* configure url_tlimits */
        for (j = registry->position[k]; j < i; j++) {
            if (AB_DEBUG_XS) printf("AB_DEBUG: run %d setup2 - stage 7.2, j=%d\n", k, j);
            tmpsv = *(av_fetch(tmpav, j - registry->position[k], 0));
            if (SvOK(tmpsv)) {
                if (AB_DEBUG_XS) printf("AB_DEBUG: run %d setup2 - stage 7.3, j=%d\n", k, j);
                registry->url_tlimit[j] = SvNV(tmpsv);
                registry->min_tlimit =
                    double2timeval(ap_min(timeval2double(registry->min_tlimit),
                                          registry->url_tlimit[j]));
                if (AB_DEBUG_XS) printf("AB_DEBUG: run %d setup2 - stage 7.3.1, j=%d, url_tlimit=%.3f sec, min tlimit so far = %.3f sec\n", k, j, registry->url_tlimit[j], timeval2double(registry->min_tlimit));
            } else
                registry->url_tlimit[j] = 0;
            if (AB_DEBUG_XS) printf("AB_DEBUG: run %d setup2 - stage 7.4, j=%d\n", k, j);
        }

        /*If the number of url_tlimits is less than
          that of urls, then assign 0 for no time limit */
        for (j = i; j < registry->position[k+1]; j++)
            registry->url_tlimit[j] = 0;

    }

    if (AB_DEBUG_XS) printf("AB_DEBUG: ready to test()\n");

    test(registry);

    if (AB_DEBUG_XS) printf("AB_DEBUG: done with test()\n");

    RETVAL = newHV();/* ready to get information stored in global variables */

    for (k = 0; k < registry->number_of_runs; k++) {
        if (registry->memory[k] >= 1) {
            AV *started = newAV();/* number of started requests for each url */
            AV *good = newAV();   /* number of good responses for each url */
            AV *failed = newAV(); /* number of bad responses for each url */
            tmpav = newAV();      /* array to keep the thread information */

            if (AB_DEBUG_XS) printf("AB_DEBUG: getting regression info for run %d\n", k);

            for (i = 0; i < registry->repeats[k]; i++) {
                AV *th_t = newAV();  /* times for processing and connecting */
                AV *th_r = newAV();  /* times for http request */
                AV *th_c = newAV();  /* connecting times */
                AV *page_contents = newAV(); /* pages read from servers */
                AV *request_headers = newAV(); /* HTTP requests sent to servers */
                AV *request_body = newAV(); /* HTTP requests sent to servers */
                AV *headers = newAV();
                AV *bytes_posted = newAV();
                AV *doc_length = newAV();
                AV *bytes_read = newAV();

                /* variables for calculating min/max/avg times*/
                int totalcon = 0, totalreq = 0, total = 0;
                int mincon = 999999, minreq = 999999, mintot = 999999;
                int maxcon = 0, maxreq = 0, maxtot = 0;

                /* byte counters */
                int total_bytes_posted = 0, total_bytes_read = 0;

                for (j = registry->position[k]; j < registry->position[k+1]; j++) {
                    struct data s = registry->stats[j][i];
                    mincon = ap_min(mincon, s.ctime);
                    minreq = ap_min(minreq, s.rtime);
                    mintot = ap_min(mintot, s.time);
                    maxcon = ap_max(maxcon, s.ctime);
                    maxreq = ap_max(maxreq, s.rtime);
                    maxtot = ap_max(maxtot, s.time);
                    totalcon += s.ctime;
                    totalreq += s.rtime;
                    total += s.time;
                    if (AB_DEBUG_XS) printf("AB_DEBUG: getting regression - stage 1 - i,j=%d,%d: mintot=%d maxtot=%d total=%d\n", i, j, mintot, maxtot, total);

                    total_bytes_posted += registry->totalposted[j];
                    total_bytes_read += registry->stats[j][i].read;

                    av_push(th_c, newSVnv(registry->stats[j][i].ctime));
                    av_push(th_r, newSVnv(registry->stats[j][i].rtime));
                    av_push(th_t, newSVnv(registry->stats[j][i].time));
                    if (AB_DEBUG_XS) printf("AB_DEBUG: getting regression - stage 1.1 - i,j=%d,%d\n", i, j);
                    if (i == 0) {
                        av_push(started, newSViv(registry->started[j]));
                        av_push(good, newSViv(registry->good[j]));
                        av_push(failed, newSViv(registry->failed[j]));
                        total_started += registry->started[j];
                        total_good += registry->good[j];
                        total_failed += registry->failed[j];
                    }

                    if (registry->memory[k] >= 2) {
                        if (AB_DEBUG_XS) printf("AB_DEBUG: getting regression - stage 1.1.0 - i,j=%d,%d  header='%s'\n", i, j, registry->stats[j][i].response_headers);
                        if (registry->stats[j][i].response_headers &&
                            strlen(registry->stats[j][i].response_headers) > 0)
                            av_push(headers, newSVpv(registry->stats[j][i].response_headers, 0));
                        else
                            av_push(headers, &PL_sv_undef);
                        if (registry->stats[j][i].request_headers &&



( run in 0.887 second using v1.01-cache-2.11-cpan-39bf76dae61 )