Skip to content

Commit 89a2d17

Browse files
committed
Add more logs
1 parent 645a43b commit 89a2d17

File tree

3 files changed

+55
-1
lines changed

3 files changed

+55
-1
lines changed

samples/cpp/benchmark_app/main.cpp

+45
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,42 @@
3737
#include "utils.hpp"
3838
// clang-format on
3939

40+
#if defined _WIN32
41+
42+
#include <windows.h>
43+
44+
#include <psapi.h>
45+
46+
int64_t getPeakMemoryUsage() {
47+
PROCESS_MEMORY_COUNTERS memCounters;
48+
GetProcessMemoryInfo(GetCurrentProcess(), &memCounters, sizeof(memCounters));
49+
return memCounters.PeakWorkingSetSize / 1000;
50+
}
51+
52+
#else
53+
54+
#include <fstream>
55+
#include <regex>
56+
#include <sstream>
57+
58+
int64_t getPeakMemoryUsage() {
59+
size_t peakMemUsageKB = 0;
60+
61+
std::ifstream statusFile("/proc/self/status");
62+
std::string line;
63+
std::regex vmPeakRegex("VmPeak:");
64+
std::smatch vmMatch;
65+
while (std::getline(statusFile, line)) {
66+
if (std::regex_search(line, vmMatch, vmPeakRegex)) {
67+
std::istringstream iss(vmMatch.suffix());
68+
iss >> peakMemUsageKB;
69+
}
70+
}
71+
return static_cast<int64_t>(peakMemUsageKB);
72+
}
73+
74+
#endif
75+
4076
namespace {
4177
bool parse_and_check_command_line(int argc, char* argv[]) {
4278
// ---------------------------Parsing and validating input
@@ -775,7 +811,16 @@ int main(int argc, char* argv[]) {
775811
if (!modelStream.is_open()) {
776812
throw std::runtime_error("Cannot open model file " + FLAGS_m);
777813
}
814+
815+
auto importModelBegin = std::chrono::steady_clock::now();
816+
778817
compiledModel = core.import_model(modelStream, device_name, device_config);
818+
819+
auto importModelEnd = std::chrono::steady_clock::now();
820+
std::cout << "Import model time: "
821+
<< std::chrono::duration_cast<std::chrono::milliseconds>(importModelEnd - importModelBegin).count() << " ms"
822+
<< std::endl;
823+
779824
modelStream.close();
780825

781826
auto duration_ms = get_duration_ms_till_now(startTime);

src/plugins/intel_npu/src/compiler_adapter/src/plugin_compiler_adapter.cpp

+7
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ std::vector<std::shared_ptr<IGraph>> PluginCompilerAdapter::compileWS(const std:
110110
const Config& config) const {
111111
OV_ITT_TASK_CHAIN(COMPILE_BLOB, itt::domains::NPUPlugin, "PluginCompilerAdapter", "compileWS");
112112

113+
auto compileNetBegin = std::chrono::steady_clock::now();
114+
113115
std::shared_ptr<NetworkDescription> initNetworkDescription;
114116
std::shared_ptr<NetworkDescription> mainNetworkDescription;
115117

@@ -188,6 +190,11 @@ std::vector<std::shared_ptr<IGraph>> PluginCompilerAdapter::compileWS(const std:
188190

189191
_logger.debug("compile end");
190192

193+
auto compileNetEnd = std::chrono::steady_clock::now();
194+
std::cout << "Compile net time: "
195+
<< std::chrono::duration_cast<std::chrono::milliseconds>(compileNetEnd - compileNetBegin).count() << " ms"
196+
<< std::endl;
197+
191198
ze_graph_handle_t initGraphHandle = nullptr;
192199
ze_graph_handle_t mainGraphHandle = nullptr;
193200

src/plugins/intel_npu/src/compiler_adapter/src/plugin_graph.cpp

+3-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,9 @@ void PluginGraph::custom_export(std::ostream& stream,
6767
} else {
6868
if (_logger.level() >= ov::log::Level::INFO) {
6969
std::stringstream str;
70-
str << "Blob size: " << _blob.size() + initBlob.size() + 4 * sizeof(size_t) + xmlSize + binSize
70+
str << "Blob size: " << _blob.size() + initBlob.size()
71+
<< std::endl;
72+
str << "Blob size with weights: " << _blob.size() + initBlob.size() + 4 * sizeof(size_t) + xmlSize + binSize
7173
<< std::endl;
7274
_logger.info(str.str().c_str());
7375
}

0 commit comments

Comments
 (0)