| 152 | } |
| 153 | |
| 154 | void dumpToLog(const Configure &Conf) const noexcept { |
| 155 | using namespace std::literals; |
| 156 | auto Nano = [](auto &&Duration) { |
| 157 | return std::chrono::nanoseconds(Duration).count(); |
| 158 | }; |
| 159 | const auto &StatConf = Conf.getStatisticsConfigure(); |
| 160 | if (StatConf.isTimeMeasuring() || StatConf.isInstructionCounting() || |
| 161 | StatConf.isCostMeasuring()) { |
| 162 | spdlog::info("==================== Statistics ===================="sv); |
| 163 | } |
| 164 | if (StatConf.isTimeMeasuring()) { |
| 165 | spdlog::info(" Total execution time: {} ns"sv, Nano(getTotalExecTime())); |
| 166 | spdlog::info(" Wasm instructions execution time: {} ns"sv, |
| 167 | Nano(getWasmExecTime())); |
| 168 | spdlog::info(" Host functions execution time: {} ns"sv, |
| 169 | Nano(getHostFuncExecTime())); |
| 170 | } |
| 171 | if (StatConf.isInstructionCounting()) { |
| 172 | spdlog::info(" Executed wasm instructions count: {}"sv, getInstrCount()); |
| 173 | } |
| 174 | if (StatConf.isCostMeasuring()) { |
| 175 | spdlog::info(" Gas costs: {}"sv, getTotalCost()); |
| 176 | } |
| 177 | if (StatConf.isInstructionCounting() && StatConf.isTimeMeasuring()) { |
| 178 | const double IPS = getInstrPerSecond(); |
| 179 | spdlog::info(" Instructions per second: {}"sv, |
| 180 | likely(!std::isnan(IPS)) |
| 181 | ? static_cast<uint64_t>(IPS) |
| 182 | : std::numeric_limits<uint64_t>::max()); |
| 183 | } |
| 184 | if (StatConf.isTimeMeasuring() || StatConf.isInstructionCounting() || |
| 185 | StatConf.isCostMeasuring()) { |
| 186 | spdlog::info("======================= End ======================"sv); |
| 187 | } |
| 188 | } |
| 189 | |
| 190 | private: |
| 191 | std::vector<uint64_t> CostTab; |
no test coverage detected