Ignore:
Timestamp:
Aug 11, 2020, 1:54:30 PM (2 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
arm-eh, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
9f1c286
Parents:
e857743
Message:

Adjsuted benchmarks to new io_ctxs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • benchmark/benchcltr.hfa

    re857743 r01c6256  
    11#pragma once
     2#include <assert.h>
     3#include <stdint.h>
    24
    3 #include <assert.h>
    4 #include <kernel.hfa>
    5 #include <thread.hfa>
    6 #include <stats.hfa>
     5#ifdef __cforall
     6        #include <kernel.hfa>
     7        #include <thread.hfa>
     8        #include <stats.hfa>
     9#else
     10#include <time.h>                                                                               // timespec
     11#include <sys/time.h>                                                                   // timeval
     12
     13enum { TIMEGRAN = 1000000000LL };                                       // nanosecond granularity, except for timeval
     14#endif
    715
    816#define BENCH_OPT_SHORT "d:p:t:SPV"
     
    5563bool procstats = false;
    5664bool viewhalts = false;
     65
     66#ifdef __cforall
    5767struct cluster * the_benchmark_cluster = 0p;
    5868struct BenchCluster {
     
    6070};
    6171
    62 void ?{}( BenchCluster & this, int flags, int stats ) {
    63         (this.self){ "Benchmark Cluster", flags };
     72void ?{}( BenchCluster & this, int num_io, const io_context_params & io_params, int stats ) {
     73        (this.self){ "Benchmark Cluster", num_io, io_params };
    6474
    6575        assert( the_benchmark_cluster == 0p );
     
    105115        }
    106116}
     117#else
     118uint64_t getTimeNsec() {
     119        timespec curr;
     120        clock_gettime( CLOCK_REALTIME, &curr );
     121        return (int64_t)curr.tv_sec * TIMEGRAN + curr.tv_nsec;
     122}
     123
     124uint64_t to_miliseconds( uint64_t durtn ) { return durtn / (TIMEGRAN / 1000LL); }
     125double to_fseconds(uint64_t durtn ) { return durtn / (double)TIMEGRAN; }
     126uint64_t from_fseconds(double sec) { return sec * TIMEGRAN; }
     127
     128
     129void wait_duration(double duration, uint64_t & start, uint64_t & end, bool is_tty) {
     130        for(;;) {
     131                usleep(100000);
     132                end = getTimeNsec();
     133                uint64_t delta = end - start;
     134                /*if(is_tty)*/ {
     135                        printf(" %.1f\r", to_fseconds(delta));
     136                        fflush(stdout);
     137                }
     138                if( delta >= from_fseconds(duration) ) {
     139                        break;
     140                }
     141        }
     142}
     143#endif
     144
    107145
    108146void bench_usage( char * argv [] ) {
Note: See TracChangeset for help on using the changeset viewer.