function processSample()

in tools/owperf/owperf.js [540:621]


function processSample(sample, activation) {

    const bi = sample.bi;

    if (bi < measurementTime.start || bi > measurementTime.stop)    {    // BI outside time frame. No further processing.
        mLog(`Sample discarded. BI exceeds measurement time frame`);
        return;
    }

    tpCounters.attempts++;    // each sample invoked in the time frame counts as one invocation attempt

    if (sample.taidError) {    // trigger activation failed - count one request, one error. No further processing.
        tpCounters.requests++;
        tpCounters.errors++;
        mLog(`Sample discarded. Trigger activation error: ${sample.taidError}`);
        return;
    }

    var ts;
    if (sample.ts) {
        ts = parseInt(sample.ts);

        if (ts >= measurementTime.start && ts <= measurementTime.stop) {    // trigger activation in time frame - count one activation, one request
            tpCounters.activations++;
            tpCounters.requests++;
        }
    }
    else
        ts = undefined;

    if (sample.aaidError) {    // action activation failed - count one request, one error. No further processing.
        tpCounters.requests++;
        tpCounters.errors++;
        mLog(`Sample discarded. Action activation error: ${sample.aaidError}`);
        return;
    }

    if (!activation) {    // no activation, so assumed incomplete. No further processing.
        mLog(`Sample discarded. Activation was not retrieved.`)
        return;
    }

    const as = parseInt(activation.start);
    const ae = parseInt(activation.end);
    const d = parseInt(activation.response.result.duration);

    if (as < measurementTime.start || ae > measurementTime.stop) {    // got activation, but it exceeds the time frame. No further processing.
        mLog(`Sample discarded. Action activation exceeded measurement time frame.`)
        return;
    }

    // Activation is in time frame, so count one activation, one request and one full invocation
    tpCounters.activations++;
    tpCounters.requests++;
    tpCounters.invocations++;

    // For full invocations, update latency counters

    const ta = (ts ? as - ts : undefined);
    const ad = ae - as;
    const oea = as - bi;
    const oer = ae - bi - d;

    updateLatSample("d", d);
    updateLatSample("ta", ta);
    updateLatSample("ad", ad);
    updateLatSample("oea", oea);
    updateLatSample("oer", oer);

    // for blocking action invocations - will be "undefined" otherwise
    const ai = sample.ai;

    const ora = (ai ? ai - ae : undefined);
    const rtt = (ai ? ai - bi : undefined);
    const ortt = (rtt ? rtt - d : undefined);

    updateLatSample("ora", ora);
    updateLatSample("rtt", rtt);
    updateLatSample("ortt", ortt);

    mLog(`${bi},\t${as},\t${ae},\t${ts},\t${ta},\t${oea},\t${oer},\t${d},\t${ad},\t${ai},\t${ora},\t${rtt},\t${ortt}`);
}