2020-06-02 19:08:38 +08:00
|
|
|
/*!
|
|
|
|
\file Performance.cpp
|
|
|
|
\brief Class to store performance of CPU
|
|
|
|
\author Màrius Montón
|
|
|
|
\date Aug 2018
|
|
|
|
*/
|
|
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
2018-09-11 00:44:54 +08:00
|
|
|
#include "Performance.h"
|
|
|
|
|
2020-06-02 19:08:38 +08:00
|
|
|
Performance* Performance::getInstance() {
|
|
|
|
if (instance == 0) {
|
|
|
|
instance = new Performance();
|
|
|
|
}
|
2018-09-11 00:44:54 +08:00
|
|
|
|
2020-06-02 19:08:38 +08:00
|
|
|
return instance;
|
2018-09-11 00:44:54 +08:00
|
|
|
}
|
|
|
|
|
2020-06-02 19:08:38 +08:00
|
|
|
Performance::Performance() {
|
|
|
|
data_memory_read = 0;
|
|
|
|
data_memory_write = 0;
|
|
|
|
code_memory_read = 0;
|
|
|
|
code_memory_write = 0;
|
|
|
|
register_read = 0;
|
|
|
|
register_write = 0;
|
|
|
|
instructions_executed = 0;
|
2018-09-27 20:32:40 +08:00
|
|
|
}
|
2018-09-11 00:44:54 +08:00
|
|
|
|
|
|
|
void Performance::dump() {
|
2020-06-02 19:08:38 +08:00
|
|
|
std::cout << std::dec << "# data memory reads: " << data_memory_read
|
|
|
|
<< std::endl;
|
|
|
|
std::cout << "# data memory writes: " << data_memory_write << std::endl;
|
|
|
|
std::cout << "# code memory reads: " << code_memory_read << std::endl;
|
|
|
|
std::cout << "# code memory writes: " << code_memory_write << std::endl;
|
|
|
|
std::cout << "# registers read: " << register_read << std::endl;
|
|
|
|
std::cout << "# registers write: " << register_write << std::endl;
|
|
|
|
std::cout << "# instructions executed: " << instructions_executed
|
|
|
|
<< std::endl;
|
2018-09-11 00:44:54 +08:00
|
|
|
}
|
|
|
|
|
2020-06-02 19:08:38 +08:00
|
|
|
Performance *Performance::instance = 0;
|