From b3b00ac7f3cdc0b140621152880284ff357a6043 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A0rius=20Mont=C3=B3n?= Date: Mon, 1 Feb 2021 11:24:53 +0100 Subject: [PATCH] more performance metrics output --- src/Simulator.cpp | 8 +++++++- src/extension_base.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Simulator.cpp b/src/Simulator.cpp index 6b7dadc..a503e7f 100644 --- a/src/Simulator.cpp +++ b/src/Simulator.cpp @@ -86,6 +86,7 @@ void process_arguments(int argc, char *argv[]) { log = Log::getInstance(); log->setLogLevel(Log::ERROR); + while ((c = getopt(argc, argv, "D:f:?")) != -1) { switch (c) { case 'D': @@ -129,6 +130,8 @@ void process_arguments(int argc, char *argv[]) { int sc_main(int argc, char *argv[]) { + Performance *perf = Performance::getInstance(); + /* Capture Ctrl+C and finish the simulation */ signal(SIGINT, intHandler); @@ -142,10 +145,13 @@ int sc_main(int argc, char *argv[]) { auto start = std::chrono::steady_clock::now(); sc_core::sc_start(); - auto end = std::chrono::steady_clock::now(); + std::chrono::duration elapsed_seconds = end - start; + double instructions = perf->getInstructions() / elapsed_seconds.count(); + std::cout << "Total elapsed time: " << elapsed_seconds.count() << "s" << std::endl; + std::cout << "Simulated " << int(std::round(instructions)) << " instr/sec" << std::endl; std::cout << "Press Enter to finish" << std::endl; std::cin.ignore(); diff --git a/src/extension_base.cpp b/src/extension_base.cpp index 666fa8b..f468445 100644 --- a/src/extension_base.cpp +++ b/src/extension_base.cpp @@ -22,7 +22,7 @@ void extension_base::setInstr(uint32_t p_instr) { m_instr = sc_dt::sc_uint<32>(p_instr); } -void extension_base::dump() { +void extension_base::dump() const { std::cout << std::hex << "0x" << m_instr << std::dec << std::endl; }