Changeset bd951f7


Ignore:
Timestamp:
May 5, 2017, 11:03:29 AM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
43426d4, 4f9636f
Parents:
e0b8ccd5
Message:

csv-data now contains monitor entry and leave timings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/benchmark/csv-data.c

    re0b8ccd5 rbd951f7  
    11#include <fstream>
     2#include <monitor>
    23#include <stdlib>
    34#include <thread>
     
    2829#endif
    2930
    30 
    31 
     31//-----------------------------------------------------------------------------
     32// coroutine context switch
    3233long long int measure_coroutine() {
    3334        const unsigned int NoOfTimes = N;
     
    4748}
    4849
     50//-----------------------------------------------------------------------------
     51// thread context switch
    4952long long int measure_thread() {
    5053        const unsigned int NoOfTimes = N;
     
    6063}
    6164
     65//-----------------------------------------------------------------------------
     66// single monitor entry
     67monitor mon_t {};
     68void dummy( mon_t * mutex m ) {}
     69
     70long long int measure_1_monitor_entry() {
     71        const unsigned int NoOfTimes = N;
     72        long long int StartTime, EndTime;
     73        mon_t mon;
     74
     75        StartTime = Time();
     76        for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) {
     77                dummy( &mon );
     78        }
     79        EndTime = Time();
     80
     81        return ( EndTime - StartTime ) / NoOfTimes;
     82}
     83
     84//-----------------------------------------------------------------------------
     85// multi monitor entry
     86void dummy( mon_t * mutex m1,  mon_t * mutex m2 ) {}
     87
     88long long int measure_2_monitor_entry() {
     89        const unsigned int NoOfTimes = N;
     90        long long int StartTime, EndTime;
     91        mon_t mon1, mon2;
     92
     93        StartTime = Time();
     94        for ( volatile unsigned int i = 0; i < NoOfTimes; i += 1 ) {
     95                dummy( &mon1, &mon2 );
     96        }
     97        EndTime = Time();
     98
     99        return ( EndTime - StartTime ) / NoOfTimes;
     100}
     101
    62102int main()
    63103{
    64         sout | time(NULL) | ',' | measure_coroutine() | ',' | measure_thread() | endl;
     104        sout | time(NULL) | ',';
     105        sout | measure_coroutine() | ',';
     106        sout | measure_thread() | ',';
     107        sout | measure_1_monitor_entry() | ',';
     108        sout | measure_2_monitor_entry() | endl;
    65109}
Note: See TracChangeset for help on using the changeset viewer.