OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [profiler.c] - Diff between revs 940 and 997

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 940 Rev 997
Line 56... Line 56...
static FILE *fprof = 0;
static FILE *fprof = 0;
 
 
/* Print out command line help */
/* Print out command line help */
void prof_help ()
void prof_help ()
{
{
  printf ("profiler [-c] [-q] -g [profile_file_name]\n");
  PRINTF ("profiler [-c] [-q] -g [profile_file_name]\n");
  printf ("\t-c\t--cumulative\t\tcumulative sum of cycles in functions\n");
  PRINTF ("\t-c\t--cumulative\t\tcumulative sum of cycles in functions\n");
  printf ("\t-q\t--quiet\t\t\tsuppress messages\n");
  PRINTF ("\t-q\t--quiet\t\t\tsuppress messages\n");
  printf ("\t-g\t--generate [profile_file_name]\n");
  PRINTF ("\t-g\t--generate [profile_file_name]\n");
  printf ("\t\t\t\t\toutput profiling results to\n");
  PRINTF ("\t\t\t\t\toutput profiling results to\n");
  printf ("\t\t\t\t\tstdout/profile_file_name\n");
  PRINTF ("\t\t\t\t\tstdout/profile_file_name\n");
}
}
 
 
/* Acquire data from profiler file */
/* Acquire data from profiler file */
int prof_acquire (char *fprofname)
int prof_acquire (char *fprofname)
{
{
Line 186... Line 186...
/* Print out profiling data */
/* Print out profiling data */
void prof_print ()
void prof_print ()
{
{
  int i, j;
  int i, j;
  if (cumulative)
  if (cumulative)
    printf ("CUMULATIVE TIMES\n");
    PRINTF ("CUMULATIVE TIMES\n");
  printf ("---------------------------------------------------------------------------\n");
  PRINTF ("---------------------------------------------------------------------------\n");
  printf ("|function name            |addr    |# calls |avg cycles  |total cyles     |\n");
  PRINTF ("|function name            |addr    |# calls |avg cycles  |total cyles     |\n");
  printf ("|-------------------------+--------+--------+------------+----------------|\n");
  PRINTF ("|-------------------------+--------+--------+------------+----------------|\n");
  for (j = 0; j < prof_nfuncs; j++) {
  for (j = 0; j < prof_nfuncs; j++) {
    int bestcyc = 0, besti = 0;
    int bestcyc = 0, besti = 0;
    for (i = 0; i < prof_nfuncs; i++)
    for (i = 0; i < prof_nfuncs; i++)
      if (prof_func[i].cum_cycles > bestcyc) {
      if (prof_func[i].cum_cycles > bestcyc) {
        bestcyc = prof_func[i].cum_cycles;
        bestcyc = prof_func[i].cum_cycles;
        besti = i;
        besti = i;
      }
      }
    i = besti;
    i = besti;
    printf ("| %-24s|%08X|%8i|%12.1f|%11i,%3.0f%%|\n",
    PRINTF ("| %-24s|%08X|%8i|%12.1f|%11i,%3.0f%%|\n",
            prof_func[i].name, prof_func[i].addr, prof_func[i].calls, ((double)prof_func[i].cum_cycles / prof_func[i].calls), prof_func[i].cum_cycles, (100. * prof_func[i].cum_cycles / prof_cycles));
            prof_func[i].name, prof_func[i].addr, prof_func[i].calls, ((double)prof_func[i].cum_cycles / prof_func[i].calls), prof_func[i].cum_cycles, (100. * prof_func[i].cum_cycles / prof_cycles));
    prof_func[i].cum_cycles = -1;
    prof_func[i].cum_cycles = -1;
  }
  }
  printf ("---------------------------------------------------------------------------\n");
  PRINTF ("---------------------------------------------------------------------------\n");
  printf ("Total %i functions, %i cycles.\n", prof_nfuncs, prof_cycles);
  PRINTF ("Total %i functions, %i cycles.\n", prof_nfuncs, prof_cycles);
  printf ("Total function calls %i/%i (max depth %i).\n", nfunccalls, ntotcalls, maxstack);
  PRINTF ("Total function calls %i/%i (max depth %i).\n", nfunccalls, ntotcalls, maxstack);
}
}
 
 
/* Set options */
/* Set options */
void prof_set (int _quiet, int _cumulative)
void prof_set (int _quiet, int _cumulative)
{
{

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.