Last change
on this file since 87 was
81,
checked in by rosiere, 16 years ago
|
- Finish Environment (and test)
- Continue predictor_unit
- Add external tools
- svn keyword "Id" set
|
-
Property svn:keywords set to
Id
|
File size:
845 bytes
|
Rev | Line | |
---|
[71] | 1 | #ifndef TIME_H |
---|
| 2 | #define TIME_H |
---|
| 3 | |
---|
| 4 | #ifdef SYSTEMC |
---|
| 5 | #include "systemc.h" |
---|
| 6 | #endif |
---|
| 7 | |
---|
| 8 | #include <string> |
---|
| 9 | #include <iostream> |
---|
| 10 | #include <sys/time.h> |
---|
| 11 | |
---|
| 12 | class Time |
---|
| 13 | { |
---|
| 14 | private : timeval time_begin; |
---|
| 15 | // private : timeval time_end; |
---|
| 16 | |
---|
| 17 | public : Time () |
---|
| 18 | { |
---|
| 19 | gettimeofday(&time_begin ,NULL); |
---|
| 20 | }; |
---|
| 21 | |
---|
| 22 | public : ~Time () |
---|
| 23 | { |
---|
| 24 | std::cout << *this; |
---|
| 25 | }; |
---|
| 26 | |
---|
| 27 | public : friend std::ostream& operator<< (std::ostream& output_stream, |
---|
| 28 | const Time & x) |
---|
| 29 | { |
---|
| 30 | timeval time_end; |
---|
| 31 | |
---|
| 32 | gettimeofday(&time_end ,NULL); |
---|
| 33 | |
---|
| 34 | uint32_t nb_cycles = static_cast<uint32_t>(sc_simulation_time()); |
---|
| 35 | |
---|
[78] | 36 | double average = static_cast<double>(nb_cycles) / static_cast<double>(time_end.tv_sec-x.time_begin.tv_sec+1); |
---|
[71] | 37 | |
---|
[78] | 38 | output_stream << "Timing : " << nb_cycles << " cycles \t(" << average << " cycles/s)" << std::endl; |
---|
[71] | 39 | |
---|
| 40 | return output_stream; |
---|
| 41 | } |
---|
| 42 | }; |
---|
| 43 | |
---|
| 44 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.