openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

bprof_stats.c (2213B)


      1 /*
      2  * 
      3  * This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      4  * 
      5  * Copyright 2007-2019 Broadcom Inc. All rights reserved.
      6  *
      7  * Profile Stats commands
      8  */
      9 #include <sal/types.h>
     10 #include <sal/core/libc.h>
     11 #include <appl/diag/shell.h>
     12 #include <soc/cmdebug.h>
     13 #include <shared/shr_bprof.h>
     14 #include <shared/bsl.h>
     15 #include <bcm/error.h>
     16 
     17 #ifdef BCM_BPROF_STATS
     18 void
     19 sh_bprof_stats(int verbose)
     20 /*
     21  * Function:     sh_prof_stats
     22  * Purpose:    Prints profile statistics.
     23  * Parameters:    verbose - includes more info if TRUE
     24  * Returns:    Nothing
     25  */
     26 {
     27     int i = 0;
     28     shr_bprof_stats_entry_t bprof_stats;
     29 
     30     cli_out("\tOP name   \tTime(usec):Total \t Avg \t   Max \t    Min \t    Runs \n");
     31     for (i = 0; i < SHR_BPROF_STATS_MAX; i++) {
     32         if (BCM_E_NONE == shr_bprof_stats_get(i, &bprof_stats)) {
     33             if (bprof_stats.runs == 1) {
     34                 cli_out("%30s = %10d %10d %10d %10d %10d \n", 
     35                         shr_bprof_stats_name(i), 
     36                         bprof_stats.total_stime,
     37                         0,
     38                         0,
     39                         0,
     40                         bprof_stats.runs);
     41             } else if (bprof_stats.runs > 1) {
     42                 cli_out("%30s = %10d %10d %10d %10d %10d \n", 
     43                         shr_bprof_stats_name(i), 
     44                         bprof_stats.total_stime,
     45                         (bprof_stats.total_stime/bprof_stats.runs),
     46                         bprof_stats.max_stime,
     47                         bprof_stats.min_stime,
     48                         bprof_stats.runs);
     49             }
     50         }
     51     }
     52     cli_out("Total boot time = %10d\n", shr_bprof_stats_time_taken());
     53 
     54     return;
     55 }
     56 
     57 char sh_prof_usage[] =
     58     "Parameters: none\n\t"
     59     "Prints current profile stats\n";
     60 
     61 /*
     62  * Function:     sh_prof
     63  * Purpose:    Print prof stats
     64  * Parameters:    u - Unit number (ignored)
     65  *        a - pointer to arguments.
     66  * Returns:    CMD_USAGE/CMD_OK
     67  */
     68 cmd_result_t
     69 sh_prof(int u, args_t *a)
     70 {
     71     COMPILER_REFERENCE(u);
     72 
     73     if (ARG_CNT(a)) {
     74     return(CMD_USAGE);
     75     }
     76     sh_bprof_stats(TRUE);
     77     return(CMD_OK);
     78 }
     79 #endif /* BCM_BPROF_STATS */