Changeset a35b458 in mainline for uspace/app/stats/stats.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/stats/stats.c

    r3061bc1 ra35b458  
    5858        size_t count;
    5959        stats_task_t *stats_tasks = stats_get_tasks(&count);
    60        
     60
    6161        if (stats_tasks == NULL) {
    6262                fprintf(stderr, "%s: Unable to get tasks\n", NAME);
    6363                return;
    6464        }
    65        
     65
    6666        printf("[taskid] [thrds] [resident] [virtual] [ucycles]"
    6767            " [kcycles] [name\n");
    68        
     68
    6969        size_t i;
    7070        for (i = 0; i < count; i++) {
     
    7777                char usuffix;
    7878                char ksuffix;
    79                
     79
    8080                bin_order_suffix(stats_tasks[i].resmem, &resmem, &resmem_suffix, true);
    8181                bin_order_suffix(stats_tasks[i].virtmem, &virtmem, &virtmem_suffix, true);
    8282                order_suffix(stats_tasks[i].ucycles, &ucycles, &usuffix);
    8383                order_suffix(stats_tasks[i].kcycles, &kcycles, &ksuffix);
    84                
     84
    8585                printf("%-8" PRIu64 " %7zu %7" PRIu64 "%s %6" PRIu64 "%s"
    8686                    " %8" PRIu64 "%c %8" PRIu64 "%c %s\n",
     
    8989                    ucycles, usuffix, kcycles, ksuffix, stats_tasks[i].name);
    9090        }
    91        
     91
    9292        free(stats_tasks);
    9393}
     
    9797        size_t count;
    9898        stats_thread_t *stats_threads = stats_get_threads(&count);
    99        
     99
    100100        if (stats_threads == NULL) {
    101101                fprintf(stderr, "%s: Unable to get threads\n", NAME);
    102102                return;
    103103        }
    104        
     104
    105105        printf("[taskid] [threadid] [state ] [prio] [cpu ] [ucycles] [kcycles]\n");
    106        
     106
    107107        size_t i;
    108108        for (i = 0; i < count; i++) {
     
    110110                        uint64_t ucycles, kcycles;
    111111                        char usuffix, ksuffix;
    112                        
     112
    113113                        order_suffix(stats_threads[i].ucycles, &ucycles, &usuffix);
    114114                        order_suffix(stats_threads[i].kcycles, &kcycles, &ksuffix);
    115                        
     115
    116116                        printf("%-8" PRIu64 " %-10" PRIu64 " %-8s %6d ",
    117117                            stats_threads[i].task_id, stats_threads[i].thread_id,
    118118                            thread_get_state(stats_threads[i].state),
    119119                            stats_threads[i].priority);
    120                        
     120
    121121                        if (stats_threads[i].on_cpu)
    122122                                printf("%6u ", stats_threads[i].cpu);
    123123                        else
    124124                                printf("(none) ");
    125                        
     125
    126126                        printf("%8" PRIu64"%c %8" PRIu64"%c\n",
    127127                            ucycles, usuffix, kcycles, ksuffix);
    128128                }
    129129        }
    130        
     130
    131131        free(stats_threads);
    132132}
     
    136136        size_t count;
    137137        stats_cpu_t *cpus = stats_get_cpus(&count);
    138        
     138
    139139        if (cpus == NULL) {
    140140                fprintf(stderr, "%s: Unable to get CPU statistics\n", NAME);
    141141                return;
    142142        }
    143        
     143
    144144        printf("[id] [MHz     ] [busy cycles] [idle cycles]\n");
    145        
     145
    146146        size_t i;
    147147        for (i = 0; i < count; i++) {
     
    150150                        uint64_t bcycles, icycles;
    151151                        char bsuffix, isuffix;
    152                        
     152
    153153                        order_suffix(cpus[i].busy_cycles, &bcycles, &bsuffix);
    154154                        order_suffix(cpus[i].idle_cycles, &icycles, &isuffix);
    155                        
     155
    156156                        printf("%10" PRIu16 " %12" PRIu64 "%c %12" PRIu64 "%c\n",
    157157                            cpus[i].frequency_mhz, bcycles, bsuffix,
     
    160160                        printf("inactive\n");
    161161        }
    162        
     162
    163163        free(cpus);
    164164}
     
    168168        size_t count;
    169169        load_t *load = stats_get_load(&count);
    170        
     170
    171171        if (load == NULL) {
    172172                fprintf(stderr, "%s: Unable to get load\n", NAME);
    173173                return;
    174174        }
    175        
     175
    176176        printf("%s: Load average: ", NAME);
    177        
     177
    178178        size_t i;
    179179        for (i = 0; i < count; i++) {
    180180                if (i > 0)
    181181                        printf(" ");
    182                
     182
    183183                stats_print_load_fragment(load[i], 2);
    184184        }
    185        
     185
    186186        printf("\n");
    187        
     187
    188188        free(load);
    189189}
     
    193193        struct timeval uptime;
    194194        getuptime(&uptime);
    195        
     195
    196196        printf("%s: Up %ld days, %ld hours, %ld minutes, %ld seconds\n",
    197197            NAME, uptime.tv_sec / DAY, (uptime.tv_sec % DAY) / HOUR,
     
    242242        bool toggle_load = false;
    243243        bool toggle_uptime = false;
    244        
     244
    245245        task_id_t task_id = 0;
    246        
     246
    247247        int i;
    248248        for (i = 1; i < argc; i++) {
    249249                int off;
    250                
     250
    251251                /* Usage */
    252252                if ((off = arg_parse_short_long(argv[i], "-h", "--help")) != -1) {
     
    254254                        return 0;
    255255                }
    256                
     256
    257257                /* All threads */
    258258                if ((off = arg_parse_short_long(argv[i], "-a", "--all")) != -1) {
     
    262262                        continue;
    263263                }
    264                
     264
    265265                /* CPUs */
    266266                if ((off = arg_parse_short_long(argv[i], "-c", "--cpus")) != -1) {
     
    269269                        continue;
    270270                }
    271                
     271
    272272                /* Threads */
    273273                if ((off = arg_parse_short_long(argv[i], "-t", "--task=")) != -1) {
     
    279279                                return -1;
    280280                        }
    281                        
     281
    282282                        task_id = tmp;
    283                        
     283
    284284                        toggle_tasks = false;
    285285                        toggle_threads = true;
    286286                        continue;
    287287                }
    288                
     288
    289289                /* Load */
    290290                if ((off = arg_parse_short_long(argv[i], "-l", "--load")) != -1) {
     
    293293                        continue;
    294294                }
    295                
     295
    296296                /* Uptime */
    297297                if ((off = arg_parse_short_long(argv[i], "-u", "--uptime")) != -1) {
     
    301301                }
    302302        }
    303        
     303
    304304        if (toggle_tasks)
    305305                list_tasks();
    306        
     306
    307307        if (toggle_threads)
    308308                list_threads(task_id, toggle_all);
    309        
     309
    310310        if (toggle_cpus)
    311311                list_cpus();
    312        
     312
    313313        if (toggle_load)
    314314                print_load();
    315        
     315
    316316        if (toggle_uptime)
    317317                print_uptime();
    318        
     318
    319319        return 0;
    320320}
Note: See TracChangeset for help on using the changeset viewer.