Last change
on this file since 95 was
88,
checked in by rosiere, 16 years ago
|
Almost complete design
with Test and test platform
|
-
Property svn:keywords set to
Id
|
File size:
1.2 KB
|
Rev | Line | |
---|
[88] | 1 | #ifndef Morpheo_Time_h |
---|
| 2 | #define Morpheo_Time_h |
---|
[71] | 3 | |
---|
| 4 | #ifdef SYSTEMC |
---|
| 5 | #include "systemc.h" |
---|
| 6 | #endif |
---|
| 7 | |
---|
| 8 | #include <string> |
---|
| 9 | #include <iostream> |
---|
| 10 | #include <sys/time.h> |
---|
| 11 | |
---|
[88] | 12 | namespace morpheo { |
---|
| 13 | |
---|
[71] | 14 | class Time |
---|
| 15 | { |
---|
[88] | 16 | #ifdef SYSTEMC |
---|
| 17 | private : double nb_cycles_begin; |
---|
| 18 | #endif |
---|
| 19 | private : timeval time_begin; |
---|
[71] | 20 | // private : timeval time_end; |
---|
| 21 | |
---|
| 22 | public : Time () |
---|
[88] | 23 | { |
---|
| 24 | #ifdef SYSTEMC |
---|
| 25 | nb_cycles_begin = sc_simulation_time(); |
---|
| 26 | #endif |
---|
| 27 | gettimeofday(&time_begin,NULL); |
---|
[71] | 28 | }; |
---|
[88] | 29 | |
---|
[71] | 30 | public : ~Time () |
---|
| 31 | { |
---|
| 32 | std::cout << *this; |
---|
| 33 | }; |
---|
| 34 | |
---|
[88] | 35 | public : friend std::ostream& operator<< (std::ostream& output, |
---|
[71] | 36 | const Time & x) |
---|
| 37 | { |
---|
| 38 | timeval time_end; |
---|
| 39 | |
---|
[88] | 40 | gettimeofday(&time_end,NULL); |
---|
[71] | 41 | |
---|
[88] | 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); |
---|
[71] | 45 | |
---|
[88] | 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; |
---|
[71] | 54 | } |
---|
| 55 | }; |
---|
| 56 | |
---|
[88] | 57 | }; // end namespace morpheo |
---|
| 58 | |
---|
[71] | 59 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.