Solving timestamps and serialization merge

Change-Id: Icd14e49c06b19e4334adbdb98efed54af029b95b


[ROCm/rocprofiler commit: def7fa710a]
This commit is contained in:
gobhardw
2023-08-24 17:45:22 +05:30
committed by Ammar Elwazir
parent 5e77e5008c
commit 6978569d1f
7 changed files with 189 additions and 88 deletions
@@ -281,7 +281,7 @@ TEST_F(HelloWorldTest, WhenRunningProfilerWithAppThenEndTimeIsGreaterThenStartTi
for (auto& itr : current_kernel_info) {
if (!(itr.begin_time).empty() && !(itr.end_time).empty()) {
EXPECT_GT(itr.end_time, itr.begin_time);
EXPECT_GT(get_timestamp_value(itr.end_time), get_timestamp_value(itr.begin_time));
}
}
}
@@ -347,7 +347,7 @@ TEST_F(VectorAddTest, WhenRunningProfilerWithAppThenEndTimeIsGreaterThenStartTim
for (auto& itr : current_kernel_info) {
if (!(itr.begin_time).empty() && !(itr.end_time).empty()) {
EXPECT_GT(itr.end_time, itr.begin_time);
EXPECT_GT(get_timestamp_value(itr.end_time), get_timestamp_value(itr.begin_time));
}
}
}
@@ -262,6 +262,22 @@ TEST_F(HelloWorldTest, WhenRunningTracerWithAppThenKernelDurationShouldBePositiv
EXPECT_GT(current_kernel_info.size(), 0);
}
// Test:4 Compares end-time is greater than start-time in current
// tracer output
TEST_F(HelloWorldTest, WhenRunningTracerWithAppThenEndTimeIsGreaterThenStartTime) {
// kernel info in current profiler run
std::vector<tracer_kernel_info_t> current_kernel_info;
GetKernelInfoForRunningApplication(&current_kernel_info);
ASSERT_TRUE(current_kernel_info.size());
for (auto& itr : current_kernel_info) {
if (!(itr.begin_time).empty() && !(itr.end_time).empty()) {
EXPECT_GT(get_timestamp_value(itr.end_time), get_timestamp_value(itr.begin_time));
}
}
}
/*
* ###################################################
@@ -20,6 +20,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#include "test_utils.h"
#include <regex>
namespace rocprofiler {
namespace tests {
@@ -130,10 +131,6 @@ void tokenize_tracer_output(std::string line, tracer_kernel_info_t& kinfo) {
std::getline(tokenStream, token, ',');
kinfo.function = token;
std::getline(tokenStream, token, ',');
kinfo.operation = token;
std::getline(tokenStream, token, ',');
kinfo.kernel_name = token;
std::getline(tokenStream, token, ',');
kinfo.begin_time = token;
std::getline(tokenStream, token, ',');
kinfo.end_time = token;
@@ -145,6 +142,19 @@ void tokenize_tracer_output(std::string line, tracer_kernel_info_t& kinfo) {
kinfo.roxtx_msg = token;
}
// get numeric value of timestamp token
uint64_t get_timestamp_value(const std::string& str) {
std::regex pattern("(\\d+)");
std::smatch match;
if (regex_search(str, match, pattern)) {
return stoul(match[1]);
} else {
return -1;
}
}
} // namespace utility
} // namespace tests
} // namespace rocprofiler
@@ -27,6 +27,7 @@ THE SOFTWARE.
#include <execinfo.h> // for backtrace
#include <algorithm>
#include <cstdint>
#include <cstdlib>
#include <fstream>
#include <sstream>
@@ -86,6 +87,9 @@ void tokenize_profiler_output(std::string line, profiler_kernel_info_t& kinfo);
// tokenize tracer output
void tokenize_tracer_output(std::string line, tracer_kernel_info_t& kinfo);
// get numeric value of timestamp token
uint64_t get_timestamp_value(const std::string& str);
} // namespace utility
} // namespace tests
} // namespace rocprofiler
@@ -94,6 +98,7 @@ void tokenize_tracer_output(std::string line, tracer_kernel_info_t& kinfo);
// path for executable
int main(int argc, char** argv);
using rocprofiler::tests::utility::get_timestamp_value;
using rocprofiler::tests::utility::GetNumberOfCores;
using rocprofiler::tests::utility::GetRunningPath;
using rocprofiler::tests::utility::is_installed_path;