예제 #1
0
Pix* timePixFunc(Pix* pix, PIX_FUNC pixFunc) {
    PROCNAME("timePixFunc");
    L_TIMER totalTimer = startTimerNested();
    Pix* result = pixFunc(pix);
    l_float32 passedTime = stopTimerNested(totalTimer);
    L_INFO("func time %.2f\n", procName, passedTime);
    return result;
}
예제 #2
0
/*!
 * \brief   regTestCleanup()
 *
 * \param[in]    rp regression test parameters
 * \return  0 if OK, 1 on error
 *
 * <pre>
 * Notes:
 *      (1) This copies anything written to the temporary file to the
 *          output file /tmp/lept/reg_results.txt.
 * </pre>
 */
l_int32
regTestCleanup(L_REGPARAMS  *rp)
{
char     result[512];
char    *results_file;  /* success/failure output in 'compare' mode */
char    *text, *message;
l_int32  retval;
size_t   nbytes;

    PROCNAME("regTestCleanup");

    if (!rp)
        return ERROR_INT("rp not defined", procName, 1);

    fprintf(stderr, "Time: %7.3f sec\n", stopTimerNested(rp->tstart));
    fprintf(stderr, "################################################\n");

        /* If generating golden files or running in display mode, release rp */
    if (!rp->fp) {
        LEPT_FREE(rp->testname);
        LEPT_FREE(rp->tempfile);
        LEPT_FREE(rp);
        return 0;
    }

        /* Compare mode: read back data from temp file */
    fclose(rp->fp);
    text = (char *)l_binaryRead(rp->tempfile, &nbytes);
    LEPT_FREE(rp->tempfile);
    if (!text) {
        rp->success = FALSE;
        LEPT_FREE(rp->testname);
        LEPT_FREE(rp);
        return ERROR_INT("text not returned", procName, 1);
    }

        /* Prepare result message */
    if (rp->success)
        snprintf(result, sizeof(result), "SUCCESS: %s_reg\n", rp->testname);
    else
        snprintf(result, sizeof(result), "FAILURE: %s_reg\n", rp->testname);
    message = stringJoin(text, result);
    LEPT_FREE(text);
    results_file = genPathname("/tmp/lept", "reg_results.txt");
    fileAppendString(results_file, message);
    retval = (rp->success) ? 0 : 1;
    LEPT_FREE(results_file);
    LEPT_FREE(message);

    LEPT_FREE(rp->testname);
    LEPT_FREE(rp);
    return retval;
}