ADT
        arm-eh
        ast-experimental
        enum
        forall-pointer-decay
        jacob/cs343-translation
        jenkins-sandbox
        new-ast
        new-ast-unique-expr
        pthread-emulation
        qualifiedEnum
      
      
        
          | 
            Last change
 on this file since fe065c3 was             c884f2d, checked in by tdelisle <tdelisle@…>, 7 years ago           | 
        
        
          | 
             
Fixed error for % of parent printing in timing sections and added more timing instrumentation 
 
           | 
        
        
          
            
              - 
Property                 mode
 set to                 
100644
               
             
           | 
        
        
          | 
            File size:
            1.2 KB
           | 
        
      
      
| Line |   | 
|---|
| 1 | //
 | 
|---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2019 University of Waterloo
 | 
|---|
| 3 | //
 | 
|---|
| 4 | // The contents of this file are covered under the licence agreement in the
 | 
|---|
| 5 | // file "LICENCE" distributed with Cforall.
 | 
|---|
| 6 | //
 | 
|---|
| 7 | // Time.h --
 | 
|---|
| 8 | //
 | 
|---|
| 9 | // Author           : Thierry Delisle
 | 
|---|
| 10 | // Created On       : Fri Mar 01 15:14:11 2019
 | 
|---|
| 11 | // Last Modified By :
 | 
|---|
| 12 | // Last Modified On :
 | 
|---|
| 13 | // Update Count     :
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #pragma once
 | 
|---|
| 17 | 
 | 
|---|
| 18 | #include "Common/Stats/Base.h"
 | 
|---|
| 19 | 
 | 
|---|
| 20 | #if defined( NO_STATISTICS )
 | 
|---|
| 21 |         #define NO_TIME_STATISTICS
 | 
|---|
| 22 | #endif
 | 
|---|
| 23 | 
 | 
|---|
| 24 | namespace Stats {
 | 
|---|
| 25 |         namespace Time {
 | 
|---|
| 26 | #               if defined(NO_TIME_STATISTICS)
 | 
|---|
| 27 |                         inline void StartGlobal() {}
 | 
|---|
| 28 | 
 | 
|---|
| 29 |                         inline void StartBlock(const char * const) {}
 | 
|---|
| 30 |                         inline void StopBlock() {}
 | 
|---|
| 31 | 
 | 
|---|
| 32 |                         inline void print() {}
 | 
|---|
| 33 | 
 | 
|---|
| 34 |                         struct BlockGuard {
 | 
|---|
| 35 |                                 BlockGuard(const char * const) {}
 | 
|---|
| 36 |                                 ~BlockGuard() {}
 | 
|---|
| 37 |                         };
 | 
|---|
| 38 | 
 | 
|---|
| 39 |                         template<typename func_t>
 | 
|---|
| 40 |                         inline void TimeBlock(const char *, func_t f) {
 | 
|---|
| 41 |                                 f();
 | 
|---|
| 42 |                         }
 | 
|---|
| 43 | #               else
 | 
|---|
| 44 |                         void StartGlobal();
 | 
|---|
| 45 | 
 | 
|---|
| 46 |                         void StartBlock(const char * const name);
 | 
|---|
| 47 |                         void StopBlock();
 | 
|---|
| 48 | 
 | 
|---|
| 49 |                         void print();
 | 
|---|
| 50 | 
 | 
|---|
| 51 |                         struct BlockGuard {
 | 
|---|
| 52 |                                 BlockGuard(const char * const name ) { StartBlock(name); }
 | 
|---|
| 53 |                                 ~BlockGuard() { StopBlock(); }
 | 
|---|
| 54 |                         };
 | 
|---|
| 55 | 
 | 
|---|
| 56 |                         template<typename func_t>
 | 
|---|
| 57 |                         inline void TimeBlock(const char * name, func_t func) {
 | 
|---|
| 58 |                                 BlockGuard guard(name);
 | 
|---|
| 59 |                                 func();
 | 
|---|
| 60 |                         }
 | 
|---|
| 61 | #               endif
 | 
|---|
| 62 |         }
 | 
|---|
| 63 | }
 | 
|---|
       
      
  Note:
 See   
TracBrowser
 for help on using the repository browser.