Skip to content

Commit

Permalink
refactor(profiler): extract split method
Browse files Browse the repository at this point in the history
  • Loading branch information
Almouro committed Apr 18, 2024
1 parent 42e3e9d commit 266d7dd
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 20 deletions.
Binary file not shown.
Binary file not shown.
Binary file modified packages/platforms/android/cpp-profiler/bin/BAMPerfProfiler-x86
Binary file not shown.
Binary file not shown.
20 changes: 0 additions & 20 deletions packages/platforms/android/cpp-profiler/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,26 +107,6 @@ long long printPerformanceMeasure(std::vector<string> pids)
return totalDuration.count();
}

std::vector<string> split(const string &str, char delimiter)
{
std::vector<string> result;
string currentResult = "";
for (char c : str)
{
if (c == delimiter || c == '\n')
{
result.push_back(currentResult);
currentResult = "";
}
else
{
currentResult += c;
}
}

return result;
}

std::vector<string> pidOf(string bundleId)
{
auto result = executeCommand("pidof " + bundleId);
Expand Down
20 changes: 20 additions & 0 deletions packages/platforms/android/cpp-profiler/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,23 @@ std::string executeCommand(std::string command)
}
return result;
}

std::vector<std::string> split(const std::string &str, char delimiter)
{
std::vector<std::string> result;
std::string currentResult = "";
for (char c : str)
{
if (c == delimiter || c == '\n')
{
result.push_back(currentResult);
currentResult = "";
}
else
{
currentResult += c;
}
}

return result;
}
1 change: 1 addition & 0 deletions packages/platforms/android/cpp-profiler/src/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
void log(const std::string &msg);
void logTimestamp();
std::string executeCommand(std::string command);
std::vector<std::string> split(const std::string &str, char delimiter);

#endif /* UTILS_H */

0 comments on commit 266d7dd

Please sign in to comment.