#ifndef TIME_H #define TIME_H #ifdef SYSTEMC #include "systemc.h" #endif #include #include #include class Time { private : timeval time_begin; // private : timeval time_end; public : Time () { gettimeofday(&time_begin ,NULL); }; public : ~Time () { std::cout << *this; }; public : friend std::ostream& operator<< (std::ostream& output_stream, const Time & x) { timeval time_end; gettimeofday(&time_end ,NULL); uint32_t nb_cycles = static_cast(sc_simulation_time()); double average = static_cast(nb_cycles) / static_cast(time_end.tv_sec-x.time_begin.tv_sec); output_stream << nb_cycles << "\t(" << average << " cycles / seconds )" << std::endl; return output_stream; } }; #endif