Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/bench.c

    r8cb6fcd r17af7d1  
    44#include <thread>
    55
    6 #include "bench.h"
     6#include <unistd.h>                                     // sysconf
     7#include <sys/times.h>                                  // times
     8#include <time.h>
     9
     10inline unsigned long long int Time() {
     11    timespec ts;
     12    clock_gettime(
     13#if defined( __linux__ )
     14         CLOCK_THREAD_CPUTIME_ID,
     15#elif defined( __freebsd__ )
     16         CLOCK_PROF,
     17#elif defined( __solaris__ )
     18         CLOCK_HIGHRES,
     19#else
     20    #error uC++ : internal error, unsupported architecture
     21#endif
     22         &ts );
     23    return 1000000000LL * ts.tv_sec + ts.tv_nsec;
     24} // Time
    725
    826//=======================================
     
    6886//=======================================
    6987
    70 coroutine CoroutineDummy {};
     88struct CoroutineDummy { coroutine_desc __cor; };
     89DECL_COROUTINE(CoroutineDummy);
    7190void main(CoroutineDummy * this) {}
    7291
     
    98117}
    99118
    100 coroutine CoroutineResume {
     119struct CoroutineResume {
    101120    int N;
     121    coroutine_desc __cor;
    102122};
     123
     124DECL_COROUTINE(CoroutineResume);
    103125
    104126void ?{}(CoroutineResume* this, int N) {
     
    128150//=======================================
    129151
    130 thread ThreadDummy {};
     152struct ThreadDummy { thread_desc __thrd; };
     153DECL_THREAD(ThreadDummy);
    131154void main(ThreadDummy * this) {}
    132155
     
    154177}
    155178
    156 thread ContextSwitch {
     179struct ContextSwitch {
    157180    int N;
    158181    long long result;
     182    thread_desc __thrd;
    159183};
     184
     185DECL_THREAD(ContextSwitch);
    160186
    161187void main(ContextSwitch * this) {   
     
    215241        DynamicTaskCreateDelete( NoOfTimes );
    216242        {
    217                 ContextSwitch dummy = { (int)NoOfTimes };               // context switch
     243                scoped(ContextSwitch) dummy = { (int)NoOfTimes };               // context switch
    218244        }
    219245        sout | "\t" | endl;
Note: See TracChangeset for help on using the changeset viewer.