Changeset a35b458 in mainline for uspace/app/rcubench/rcubench.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/rcubench/rcubench.c

    r3061bc1 ra35b458  
    6161        size_t nthreads;
    6262        futex_t done_threads;
    63        
     63
    6464        futex_t bench_fut;
    6565} bench_t;
     
    7272        const size_t iters = bench->iters;
    7373        int val = 0;
    74        
     74
    7575        for (size_t i = 0; i < iters; ++i) {
    7676                __SYSCALL1(SYS_FUTEX_WAKEUP, (sysarg_t) &val);
     
    8383        const size_t iters = bench->iters;
    8484        futex_t loc_fut = FUTEX_INITIALIZER;
    85        
     85
    8686        for (size_t i = 0; i < iters; ++i) {
    8787                futex_lock(&loc_fut);
     
    9696        const size_t iters = bench->iters;
    9797        futex_t loc_fut = FUTEX_INITIALIZER;
    98        
     98
    9999        for (size_t i = 0; i < iters; ++i) {
    100100                futex_down(&loc_fut);
     
    108108{
    109109        bench_t *bench = (bench_t*)arg;
    110        
     110
    111111        bench->func(bench);
    112        
     112
    113113        /* Signal another thread completed. */
    114114        futex_up(&bench->done_threads);
     
    118118{
    119119        assert(1 <= bench->nthreads);
    120        
     120
    121121        if (2 <= bench->nthreads) {
    122122                printf("Creating %zu additional threads...\n", bench->nthreads - 1);
    123123        }
    124        
     124
    125125        /* Create and run the first nthreads - 1 threads.*/
    126126        for (size_t k = 1; k < bench->nthreads; ++k) {
     
    134134                thread_detach(tid);
    135135        }
    136        
     136
    137137        /*
    138138         * Run the last thread in place so that we create multiple threads
     
    141141         */
    142142        thread_func(bench);
    143        
     143
    144144        printf("Waiting for remaining threads to complete.\n");
    145        
     145
    146146        /* Wait for threads to complete. */
    147147        for (size_t k = 0; k < bench->nthreads; ++k) {
     
    168168{
    169169        va_list args;
    170        
     170
    171171        va_start(args, fmt);
    172172        vfprintf(results_fd, fmt, args);
    173173        va_end(args);
    174        
     174
    175175        va_start(args, fmt);
    176176        vprintf(fmt, args);
     
    202202
    203203        futex_initialize(&bench->bench_fut, 1);
    204        
     204
    205205        if (0 == str_cmp(argv[1], "sys-futex")) {
    206206                bench->func = kernel_futex_bench;
     
    213213                return false;
    214214        }
    215        
     215
    216216        bench->name = argv[1];
    217        
     217
    218218        /* Determine iteration count. */
    219219        uint32_t iter_cnt = 0;
     
    226226                return false;
    227227        }
    228        
     228
    229229        /* Determine thread count. */
    230230        uint32_t thread_cnt = 0;
     
    237237                return false;
    238238        }
    239        
     239
    240240        return true;
    241241}
     
    245245        const char *err = "(error)";
    246246        bench_t bench;
    247        
     247
    248248        futex_initialize(&bench.done_threads, 0);
    249        
     249
    250250        if (!parse_cmd_line(argc, argv, &bench, &err)) {
    251251                printf("%s\n", err);
     
    253253                return -1;
    254254        }
    255        
     255
    256256        open_results();
    257        
     257
    258258        print_res("Running '%s' futex bench in '%zu' threads with '%zu' iterations.\n",
    259259                bench.name, bench.nthreads, bench.iters);
    260        
     260
    261261        struct timeval start, end;
    262262        getuptime(&start);
    263        
     263
    264264        run_threads_and_wait(&bench);
    265        
     265
    266266        getuptime(&end);
    267267        int64_t duration = tv_sub_diff(&end, &start);
    268        
     268
    269269        uint64_t secs = (uint64_t)duration / 1000 / 1000;
    270270        uint64_t total_iters = (uint64_t)bench.iters * bench.nthreads;
    271271        uint64_t iters_per_sec = 0;
    272        
     272
    273273        if (0 < duration) {
    274274                iters_per_sec = total_iters * 1000 * 1000 / duration;
    275275        }
    276        
     276
    277277        print_res("Completed %" PRIu64 " iterations in %" PRId64  " usecs (%" PRIu64
    278278                " secs); %" PRIu64 " iters/sec\n",
     
    280280
    281281        close_results();
    282        
     282
    283283        return 0;
    284284}
Note: See TracChangeset for help on using the changeset viewer.