Changeset 88 for trunk/IPs/systemC/processor/Morpheo/Common/include/Time.h
- Timestamp:
- Dec 10, 2008, 7:31:39 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Common/include/Time.h
r81 r88 1 #ifndef TIME_H2 #define TIME_H1 #ifndef Morpheo_Time_h 2 #define Morpheo_Time_h 3 3 4 4 #ifdef SYSTEMC … … 10 10 #include <sys/time.h> 11 11 12 namespace morpheo { 13 12 14 class Time 13 15 { 14 private : timeval time_begin; 16 #ifdef SYSTEMC 17 private : double nb_cycles_begin; 18 #endif 19 private : timeval time_begin; 15 20 // private : timeval time_end; 16 21 17 22 public : Time () 18 { 19 gettimeofday(&time_begin ,NULL); 23 { 24 #ifdef SYSTEMC 25 nb_cycles_begin = sc_simulation_time(); 26 #endif 27 gettimeofday(&time_begin,NULL); 20 28 }; 21 29 22 30 public : ~Time () 23 31 { … … 25 33 }; 26 34 27 public : friend std::ostream& operator<< (std::ostream& output _stream,35 public : friend std::ostream& operator<< (std::ostream& output, 28 36 const Time & x) 29 37 { 30 38 timeval time_end; 31 39 32 gettimeofday(&time_end 40 gettimeofday(&time_end,NULL); 33 41 34 uint32_t nb_cycles = static_cast<uint32_t>(sc_simulation_time()); 35 36 double average = static_cast<double>(nb_cycles) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1);42 #ifdef SYSTEMC 43 double nb_cycles_end = sc_simulation_time(); 44 double average = static_cast<double>(nb_cycles_end-x.nb_cycles_begin+1) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1); 37 45 38 output_stream << "Timing : " << nb_cycles << " cycles \t(" << average << " cycles/s)" << std::endl; 39 40 return output_stream; 46 output << "Timing : " << nb_cycles_end << " cycles \t(" << average << " cycles/s)" << std::endl; 47 #else 48 double average = static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1); 49 50 output << "Timing : " average << " s" << std::endl; 51 #endif 52 53 return output; 41 54 } 42 55 }; 43 56 57 }; // end namespace morpheo 58 44 59 #endif
Note: See TracChangeset
for help on using the changeset viewer.