예제 #1
0
void __print_ThreadCreated(FILE *fOut,
                           PERF_Private *perf,
                           unsigned long ulThreadID,
                           unsigned long ulThreadName)
{
    /* get debug private structure */
    PERF_PRINT_Private *me = perf->cip.pDebug;

    fprintf(fOut, "%s%ld.%06ld%sThread%s%ld%s%c%c%c%c%s" __LINE_END__,
            me->prompt, TIME_SECONDS(perf->time), TIME_MICROSECONDS(perf->time),
            me->info,
            me->csv ? "," : "(pid=",
            ulThreadID,
            me->csv ? "," : " name=",
            PERF_FOUR_CHARS(ulThreadName),
            me->csv ? "" : ")");

    print_print_location(perf, fOut, 2);
}
예제 #2
0
static void print_rate_info(FILE *fOut,
                            unsigned long ID, PERF_MODULETYPE modulesAndFlags,
                            unsigned long size, long n)
{
    unsigned long module1 = modulesAndFlags & PERF_ModuleMask;
    unsigned long module2 = (modulesAndFlags >> PERF_ModuleBits) & PERF_ModuleMask;
    int xfering  = PERF_IsXfering(modulesAndFlags);
    int sendIx   = (PERF_GetSendRecv(modulesAndFlags) >> 28) & 3;
    int sending  = PERF_IsSending(modulesAndFlags);
    int frame    = PERF_IsFrame  (modulesAndFlags);

    fprintf(fOut, "%c%c%c%c %s %ld+ %s[0x%lX]%s%s%s%s",
            PERF_FOUR_CHARS(ID),
            xfering ? "xfering" : sendRecvTxt[sendIx],
            n,
            frame ? "frames" : "buffers",
            size,
            (xfering || !sending) ? " from " : " to ",
            (module1 < PERF_ModuleMax ? PERF_ModuleTypes[module1] : "INVALID"),
            xfering ? " to " : "",
            xfering ? (module2 < PERF_ModuleMax ? PERF_ModuleTypes[module2] : "INVALID") : "");
}
예제 #3
0
int PERF_PRINT_setup(PERF_Private *perf, PERF_MODULETYPE eModule)
{
    PERF_PRINT_Private *me = perf->cip.pDebug;
    /* we concatenate the following fields for a unique and informative ID:
       PID, address, domain, type */

    /* common variables that differ from CSV and text output */
    char const * const * domains, *missing, *separator;

    /* data needed for info field */
    unsigned long type = eModule & PERF_ModuleMask;

    /* set up common variables */
    if (me->csv)
    {
        domains = (char const * const *) domains_normal;
        missing = separator = ",";
        me->prompt = "";
        print_header(me->fDebug);
    }
    else
    {
        domains = (char const * const *) domains_csv;
        missing = "";
        separator = ", ";
        me->prompt = "<";
    }

    me->info = (char *) malloc(3+9+1+8+2+6+4+2+7+12+8+16+2 + 100);
    if (me->info)
    {

        sprintf(me->info,
                "%s"           /* info separator start */
                "%ld"          /* PID */
                "%s"           /* separator */
                "%08lx"        /* handle */
                "%s"           /* separator */
                "%s"           /* name tag */            
                "%c%c%c%c"     /* name (fourcc) */
                "%s"           /* separator */
                "%s"           /* domain tag */
                "%s%s%s%s%s%s" /* domain */
                "%s"           /* module tag */
                "%s"           /* module */
                "%s"           /* info separator end */
                ,
                me->csv ? separator : "> {",
                perf->ulPID,
                me->csv ? separator : "-",
                (unsigned long) perf,
                separator,
                /* name tag */
                me->csv ? "" : "name: ",
                /* name (fourcc) */
                PERF_FOUR_CHARS(perf->ulID),
                separator,
                /* domain tag */
                me->csv ? "" : "domain: ",
                /* domain */
                (eModule & PERF_ModuleAudioDecode) ? domains[0] : missing,
                (eModule & PERF_ModuleVideoDecode) ? domains[1] : missing,
                (eModule & PERF_ModuleImageDecode) ? domains[2] : missing,
                (eModule & PERF_ModuleAudioEncode) ? domains[3] : missing,
                (eModule & PERF_ModuleVideoEncode) ? domains[4] : missing,
                (eModule & PERF_ModuleImageEncode) ? domains[5] : missing,
                /* module tag */
                me->csv ? "" : ", module: ",  /* note: separator added for CSV */
                /* module */
                (type < PERF_ModuleMax) ? PERF_ModuleTypes[type] : "INVALID",
                /* info separator end */
                me->csv ? separator : "} ");
    }

    /* we succeed if we could allocate the info string */
    return(me->info != NULL);
}
예제 #4
0
PERF_PRINT_Private *
PERF_PRINT_create(PERF_Private *perf, PERF_Config *config,
                  PERF_MODULETYPE eModule)
{
    char *fOutFile = NULL;
    FILE *fOut = NULL;
    PERF_PRINT_Private *me =
    perf->cip.pDebug = malloc(sizeof(PERF_PRINT_Private));

    if (me)
    {
        me->csv = config->csv;
        me->fDebug = me->fPrint = NULL;
        me->info = me->prompt = NULL;
        perf->uMode |= PERF_Mode_Print;

#ifdef __PERF_LOG_LOCATION__
        /* no location information yet */
        clear_print_location(perf);
#endif
        /* set up fDebug and fPrint file pointers */
        if (config->log_file)
        {
            /* open log file unless STDOUT or STDERR is specified */
            if (!strcasecmp(config->log_file, "STDOUT")) fOut = stdout;
            else if (!strcasecmp(config->log_file, "STDERR")) fOut = stderr;
            else
            {
                /* expand file name with PID and name */
                fOutFile = (char *) malloc (strlen(config->log_file) + 32);
                if (fOutFile)
                {
                    sprintf(fOutFile, "%s-%05lu-%08lx-%c%c%c%c.log",
                            config->log_file, perf->ulPID, (unsigned long) perf,
                            PERF_FOUR_CHARS(perf->ulID));
                    fOut = fopen(fOutFile, "at");

                    /* free new file name */
                    free(fOutFile);
                    fOutFile = NULL;
                }

                /* if could not open output, set it to STDOUT */
                if (!fOut) fOut = stdout;
            }
            me->fDebug = me->fPrint = fOut;
                                       
        }
        else if (config->detailed_debug)
        {
            /* detailed debug is through stderr */
            me->fDebug = me->fPrint = stderr;
        }
        else if (config->debug)
        {
            /* normal debug is through stdout (buffers are not printed) */
            me->fDebug = stdout;
            me->fPrint = NULL;
        }

        PERF_PRINT_setup(perf, eModule);

        if (me->fDebug) __print_Create(me->fDebug, perf);
    }

    return(me);
}
예제 #5
0
void __rt_Done(PERF_Private *perf)
{
    /* get real-time private structure */
    PERF_RT_Private *me = perf->cip.pRT;

    /* print summaries if required */
    if (me->summary)
    {
        /* uptime summary */
        if (me->dUptime)
        {
            /* get last uptime */
            start_stop_uptime(me->dUptime, 0);

            fprintf(me->fRt, "rtPERF: ARM CPU-load for%s %c%c%c%c component: ",
                    me->needSteadyState ? " steady state of" : "",
                    PERF_FOUR_CHARS(perf->ulID));

            if (me->dUptime->success && me->dUptime->start_uptime)
            {
                double load = (100. * (me->dUptime->start_uptime -
                                       me->dUptime->start_idletime) /
                               me->dUptime->start_uptime);
                if (me->dUptime->n)
                {
                    double x = me->dUptime->x / me->dUptime->n;
                    double xx = me->dUptime->xx / me->dUptime->n;
                    xx = my_sqrt(xx - x * x);
                    if (me->debug & 2)
                    {
                        fprintf(me->fRt, ": %.3g +- %.3g%%\n"
                                "(temporal difference is: %.3g)\n",
                                load, xx, x - load);
                    }
                    else
                    {
                        fprintf(me->fRt, ": %.3g +- %.3g%%\n",
                                load, xx);
                    }
                }
                else
                {
                    fprintf(me->fRt, "%.3g%%\n", load);
                }
            }
            else
            {
                fprintf(me->fRt, "FAILED TO CALCULATE\n");
            }
        }

        /* rate summary */
        if (me->nDRate)
        {
            int i;
            for (i = 0; i < me->nDRate; i++)
            {
                if (me->dRate[i].n >= MIN_FRAMES_FOR_RATE &&
                        ((me->debug & 4) || me->dRate[i].tn0 >= MIN_FRAMES_FOR_RATE))
                {

                    double x = me->dRate[i].x * 1e-6 / me->dRate[i].n;

                    double s = (me->dRate[i].xx ?
                                (me->dRate[i].x * (double) me->dRate[i].x /
                                 me->dRate[i].xx / me->dRate[i].n) : 1);

                    fprintf(me->fRt, "rtPERF: ");
                    print_rate_info(me->fRt,
                                    perf->ulID, me->dRate[i].modulesAndFlags,
                                    me->dRate[i].size, me->dRate[i].n);
                    if (x > 0)
                    {
                        if (me->dRate[i].an)
                        {
                            double x2 = me->dRate[i].ax / me->dRate[i].an;
                            double xx = me->dRate[i].axx / me->dRate[i].an;
                            xx = my_sqrt(xx - x2 * x2);
                            if (me->debug & 2)
                            {
                                fprintf(me->fRt, ": %.3g +- %.3g fps (s=%.3g)\n"
                                        "(temporal difference is: %.3g)\n",
                                        1/x, xx, s, x2-1/x);
                            }
                            else
                            {
                                fprintf(me->fRt, ": %.3g +- %.3g fps (s=%.3g)\n",
                                        1/x, xx, s);
                            }
                        }
                        else
                        {
                            fprintf(me->fRt, ": %.3g fps (s=%.3g)\n", 1/x, s);
                        }
                    }
                    else
                    {
                        fprintf(me->fRt, ": FAILED TO CALCULATE\n");
                    }
                }
            }
        }

        /* shot-to-shot summary */
        if (me->dSTS)
        {
            if (me->dSTS->dABurst2.n > 0)
            {
                count_delay(me, "Avg. modified burst shot-to-shot", &me->dSTS->dABurst2, 0);
            }
            if (me->dSTS->dABurst.n > 0)
            {
                count_delay(me, "Avg. raw burst shot-to-shot", &me->dSTS->dABurst, 0);
            }
            if (me->dSTS->dSingle.n > 0)
            {
                count_delay(me, "Avg. single shot-to-shot", &me->dSTS->dSingle, -1);
            }
        }
    }
}
예제 #6
0
PERF_RT_Private *
PERF_RT_create(PERF_Private *perf, PERF_Config *config,
               PERF_MODULETYPE eModule)
{
    char *fOutFile = NULL;
    FILE *fOut = NULL;

    /* check if we support this component */
    if (perf->ulID != PERF_FOURS("CAM_") && perf->ulID != PERF_FOURS("CAMT") &&
            perf->ulID != PERF_FOURS("VP__") && perf->ulID != PERF_FOURS("VP_T") &&
            perf->ulID != PERF_FOURS("VD__") && perf->ulID != PERF_FOURS("VD_T") &&
            perf->ulID != PERF_FOURS("VE__") && perf->ulID != PERF_FOURS("VE_T"))
    {
        /* if we don't support this component, we don't create the real-time
           interface */
        return (NULL);
    }

    PERF_RT_Private *me =
        perf->cip.pRT = malloc(sizeof(PERF_RT_Private));

    if (me)
    {
        int succeed = 1;

        /* we track steady state on the component thread only */
        me->needSteadyState = (perf->ulID & 0xff) == 'T';
        me->steadyState = 0;

        /* allocate rate tracking structures */
        me->maxDRate = MAX_RATES_TRACKED;
        me->dRate = malloc(sizeof(PERF_RTdata_rate) * me->maxDRate);
        succeed = succeed && me->dRate;

        me->decoder = (perf->ulID == PERF_FOURS("VD__") || perf->ulID == PERF_FOURS("VD_T"));
        me->encoder = (perf->ulID == PERF_FOURS("VE__") || perf->ulID == PERF_FOURS("VE_T"));
        me->nDRate = 0;

        /* allocate shot-to-shot tracking structures */
        if (succeed && perf->ulID == PERF_FOURS("CAMT"))
        {
            me->dSTS = malloc(sizeof(PERF_RTdata_sts));
            succeed = succeed && me->dSTS;
            if (me->dSTS)
            {
                init_delay(&me->dSTS->dBurst, -1);   /* no first timestamp yet */
                init_delay(&me->dSTS->dABurst, 0);
                init_delay(&me->dSTS->dBurst2, 0);
                init_delay(&me->dSTS->dABurst2, 0);
                init_delay(&me->dSTS->dSingle, -1);  /* no first timestamp yet */
                me->dSTS->size_max = me->dSTS->size_min = me->dSTS->capturing = 0;
            }
        }
        else
        {
            me->dSTS = NULL;
        }

        /* allocate uptime tracking structures */

        /* :NOTE: for now we restrict creations of uptime to steady state
            only */
        if (succeed && !uptime_started && me->needSteadyState &&
                !(perf->uMode & PERF_Mode_Replay))
        {
            me->dUptime = malloc(sizeof(PERF_RTdata_uptime));
            succeed = succeed && me->dUptime;

            if (succeed)
            {
                uptime_started = 1;
                me->dUptime->measuring = 0;
                me->dUptime->last_idletime = me->dUptime->last_uptime = 0;
                me->dUptime->start_idletime = me->dUptime->start_uptime = 0;
                me->dUptime->success = 1;
                me->dUptime->xx = me->dUptime->x = me->dUptime->n = 0;
                TIME_GET(me->dUptime->last_reporting);
            }
        }
        else
        {
            me->dUptime = NULL;
        }

        /* configuration */
        me->summary     = config->rt_summary != 0;
        me->debug       = config->rt_debug & 0x1FF;
        me->detailed    = (config->rt_detailed > 2) ? 2 : (int) config->rt_detailed;

        me->granularity = (config->rt_granularity < 1) ? 1 :
                          (config->rt_granularity > MAX_GRANULARITY) ?
                          MAX_GRANULARITY : (long) config->rt_granularity;
        me->granularity *= 1000000;  /* convert to microsecs */
        TIME_COPY(me->first_time, perf->time);

        /* if we do not care about detailed statistics, only report significant
           statistics for each component */
        if (succeed && !me->detailed)
        {
            /* VP_T - display rate */
            if (perf->ulID == PERF_FOURS("VP_T"))
            {
                me->only_moduleandflags = PERF_FlagSending | PERF_FlagFrame | PERF_ModuleHardware;
            }
            /* VD_T - decode rate */
            else if (perf->ulID == PERF_FOURS("VD_T"))
            {
                me->only_moduleandflags = PERF_FlagSending | PERF_FlagFrame | PERF_ModuleLLMM;
            }
            /* VE_T - encode rate */
            else if (perf->ulID == PERF_FOURS("VE_T"))
            {
                me->only_moduleandflags = PERF_FlagSending | PERF_FlagFrame | PERF_ModuleLLMM;
            }
            /* CAMT - capture rate */
            else if (perf->ulID == PERF_FOURS("CAMT"))
            {
                me->only_moduleandflags = PERF_FlagReceived | PERF_FlagFrame | PERF_ModuleHardware;
            }
            /* otherwise, we don't care about rates */
            else
            {
                free(me->dRate);
                me->dRate = NULL;
                me->maxDRate = 0;
            }
        }

        /* set up fRt file pointers */
        if (config->rt_file && succeed)
        {
            /* open log file unless STDOUT or STDERR is specified */
            if (!strcasecmp(config->rt_file, "STDOUT")) fOut = stdout;
            else if (!strcasecmp(config->rt_file, "STDERR")) fOut = stderr;
            else
            {
                /* expand file name with PID and name */
                fOutFile = (char *) malloc (strlen(config->rt_file) + 32);
                if (fOutFile)
                {
                    sprintf(fOutFile, "%s-%05lu-%08lx-%c%c%c%c.log",
                            config->rt_file, perf->ulPID, (unsigned long) perf,
                            PERF_FOUR_CHARS(perf->ulID));
                    fOut = fopen(fOutFile, "at");

                    /* free new file name */
                    free(fOutFile);
                    fOutFile = NULL;
                }

                /* if could not open output, set it to STDOUT */
                if (!fOut) fOut = stderr;
            }
            me->fRt = fOut;
        }

        /* if we had allocation failures, free resources and return NULL */
        if (succeed)
        {
            perf->uMode |= PERF_Mode_RealTime;
        }
        else
        {
            PERF_RT_done(perf);
            me = NULL;
        }
    }

    return(me);
}