mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Merge pull request #555 from nehasharan/nehasharan/csvexport_messages
Added an option to print out "messages" while exporting a .trace file to CSV using "csvexport" utility
This commit is contained in:
commit
396d4f6f3c
@ -29,6 +29,7 @@ void print_usage_exit(int e)
|
|||||||
fprintf(stderr, " -c, --case Case sensitive filtering\n");
|
fprintf(stderr, " -c, --case Case sensitive filtering\n");
|
||||||
fprintf(stderr, " -e, --self Get self times\n");
|
fprintf(stderr, " -e, --self Get self times\n");
|
||||||
fprintf(stderr, " -u, --unwrap Report each zone event\n");
|
fprintf(stderr, " -u, --unwrap Report each zone event\n");
|
||||||
|
fprintf(stderr, " -m, --messages Report only messages\n");
|
||||||
|
|
||||||
exit(e);
|
exit(e);
|
||||||
}
|
}
|
||||||
@ -40,6 +41,7 @@ struct Args {
|
|||||||
bool case_sensitive;
|
bool case_sensitive;
|
||||||
bool self_time;
|
bool self_time;
|
||||||
bool unwrap;
|
bool unwrap;
|
||||||
|
bool unwrapMessages;
|
||||||
};
|
};
|
||||||
|
|
||||||
Args parse_args(int argc, char** argv)
|
Args parse_args(int argc, char** argv)
|
||||||
@ -49,7 +51,7 @@ Args parse_args(int argc, char** argv)
|
|||||||
print_usage_exit(1);
|
print_usage_exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Args args = { "", ",", "", false, false, false };
|
Args args = { "", ",", "", false, false, false, false };
|
||||||
|
|
||||||
struct option long_opts[] = {
|
struct option long_opts[] = {
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
@ -58,11 +60,12 @@ Args parse_args(int argc, char** argv)
|
|||||||
{ "case", no_argument, NULL, 'c' },
|
{ "case", no_argument, NULL, 'c' },
|
||||||
{ "self", no_argument, NULL, 'e' },
|
{ "self", no_argument, NULL, 'e' },
|
||||||
{ "unwrap", no_argument, NULL, 'u' },
|
{ "unwrap", no_argument, NULL, 'u' },
|
||||||
|
{ "messages", no_argument, NULL, 'm' },
|
||||||
{ NULL, 0, NULL, 0 }
|
{ NULL, 0, NULL, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
int c;
|
int c;
|
||||||
while ((c = getopt_long(argc, argv, "hf:s:ceu", long_opts, NULL)) != -1)
|
while ((c = getopt_long(argc, argv, "hf:s:ceum", long_opts, NULL)) != -1)
|
||||||
{
|
{
|
||||||
switch (c)
|
switch (c)
|
||||||
{
|
{
|
||||||
@ -84,6 +87,9 @@ Args parse_args(int argc, char** argv)
|
|||||||
case 'u':
|
case 'u':
|
||||||
args.unwrap = true;
|
args.unwrap = true;
|
||||||
break;
|
break;
|
||||||
|
case 'm':
|
||||||
|
args.unwrapMessages = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
print_usage_exit(1);
|
print_usage_exit(1);
|
||||||
break;
|
break;
|
||||||
@ -198,6 +204,38 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
auto worker = tracy::Worker(*f);
|
auto worker = tracy::Worker(*f);
|
||||||
|
|
||||||
|
if (args.unwrapMessages)
|
||||||
|
{
|
||||||
|
const auto& msgs = worker.GetMessages();
|
||||||
|
|
||||||
|
if (msgs.size() > 0)
|
||||||
|
{
|
||||||
|
std::vector<const char*> columnsForMessages;
|
||||||
|
columnsForMessages = {
|
||||||
|
"MessageName", "total_ns"
|
||||||
|
};
|
||||||
|
std::string headerForMessages = join(columnsForMessages, args.separator);
|
||||||
|
printf("%s\n", headerForMessages.data());
|
||||||
|
|
||||||
|
for(auto& it : msgs)
|
||||||
|
{
|
||||||
|
std::vector<std::string> values(columnsForMessages.size());
|
||||||
|
|
||||||
|
values[0] = worker.GetString(it->ref);
|
||||||
|
values[1] = std::to_string(it->time);
|
||||||
|
|
||||||
|
std::string row = join(values, args.separator);
|
||||||
|
printf("%s\n", row.data());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
printf("There are currently no messages!\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
while (!worker.AreSourceLocationZonesReady())
|
while (!worker.AreSourceLocationZonesReady())
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
std::this_thread::sleep_for(std::chrono::milliseconds(10));
|
||||||
|
Loading…
Reference in New Issue
Block a user