mirror of
https://gitee.com/openharmony/developtools_profiler
synced 2025-02-25 13:20:37 +00:00
commit
2a26254b6e
@ -144,6 +144,7 @@ static inline std::string StringFormat(const char* fmt, ...)
|
||||
|
||||
va_start(vargs, fmt);
|
||||
if (vsnprintf_s(buf, sizeof(buf), sizeof(buf) - 1, format.c_str(), vargs) < 0) {
|
||||
va_end(vargs);
|
||||
return "";
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,7 @@ int main(int agrc, char* agrv[])
|
||||
|
||||
PluginModuleStruct* cpuPlugin = (PluginModuleStruct*)dlsym(handle, "g_pluginModule");
|
||||
if (cpuPlugin == nullptr) {
|
||||
dlclose(handle);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -120,6 +121,7 @@ int main(int agrc, char* agrv[])
|
||||
}
|
||||
}
|
||||
cpuPlugin->callbacks->onPluginSessionStop();
|
||||
dlclose(handle);
|
||||
}
|
||||
|
||||
sleep(PROCESS_SLEEP_TIME);
|
||||
|
@ -37,13 +37,17 @@ void IoTest()
|
||||
// 一次写100K数据,写10次
|
||||
int count = 0;
|
||||
FILE* writeFp = fopen(writeFile.c_str(),"w");
|
||||
if (writeFp == nullptr) {
|
||||
printf("fopen() error");
|
||||
return;
|
||||
}
|
||||
while (count < g_testCount) {
|
||||
fwrite(const_cast<char*>(str.c_str()), 1, BLOCK_LEN, writeFp);
|
||||
(void)fwrite(const_cast<char*>(str.c_str()), 1, BLOCK_LEN, writeFp);
|
||||
fflush(writeFp);
|
||||
fsync(fileno(writeFp));
|
||||
count++;
|
||||
}
|
||||
fclose(writeFp);
|
||||
(void)fclose(writeFp);
|
||||
|
||||
// delete file
|
||||
std::string command = "rm " + writeFile;
|
||||
@ -85,7 +89,8 @@ int main(int agrc, char* agrv[])
|
||||
std::vector<uint8_t> dataBuffer(diskioPlugin->resultBufferSizeHint);
|
||||
diskioPlugin->callbacks->onPluginSessionStart(configBuffer.data(), configLength);
|
||||
while (g_testCount--) {
|
||||
int len = diskioPlugin->callbacks->onPluginReportResult(dataBuffer.data(), diskioPlugin->resultBufferSizeHint);
|
||||
int len = diskioPlugin->callbacks->onPluginReportResult(dataBuffer.data(),
|
||||
diskioPlugin->resultBufferSizeHint);
|
||||
std::cout << "test:filler buffer length = " << len << std::endl;
|
||||
|
||||
if (len > 0) {
|
||||
@ -107,6 +112,7 @@ int main(int agrc, char* agrv[])
|
||||
sleep(1);
|
||||
}
|
||||
diskioPlugin->callbacks->onPluginSessionStop();
|
||||
dlclose(handle);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -431,7 +431,8 @@ bool HilogPlugin::TimeStringToNS(const char* data, struct timespec *tsTime)
|
||||
if (snprintf_s(buff, sizeof(buff), sizeof(buff) - 1, "%ld.%09u\n", timetTime, nsec) < 0) {
|
||||
HILOG_ERROR(LOG_CORE, "%s:snprintf_s error", __func__);
|
||||
}
|
||||
for (size_t i = 0; i < strlen(buff) && protoConfig_.need_record(); i++) {
|
||||
size_t buffSize = strlen(buff);
|
||||
for (size_t i = 0; i < buffSize && protoConfig_.need_record(); i++) {
|
||||
dataBuffer_.push_back(buff[i]);
|
||||
}
|
||||
|
||||
|
@ -131,6 +131,8 @@ bool ElfFile::ParsePrgHeaders()
|
||||
}
|
||||
ret = read(fd_, phdrsBuf, phdrSize * numPhdrs);
|
||||
if (ret != static_cast<int64_t>(phdrSize * numPhdrs)) {
|
||||
delete[] phdrsBuf;
|
||||
phdrsBuf = nullptr;
|
||||
return false;
|
||||
}
|
||||
char *phdrBuf = phdrsBuf;
|
||||
|
@ -165,6 +165,7 @@ static uint64_t GetProcessMeminfo(const std::string& matchingItem)
|
||||
char* flag = fgets(line, sizeof(line), smapsRollupInfo);
|
||||
if (flag == nullptr) {
|
||||
HiLog::Error(LABEL, "The parameter was not found.");
|
||||
(void)fclose(smapsRollupInfo);
|
||||
return 0;
|
||||
}
|
||||
uint64_t meminfo = 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user