mirror of
https://gitlab.freedesktop.org/cairo/cairo.git
synced 2025-12-24 21:50:19 +01:00
[perf] Support parsing reports from stdin
This commit is contained in:
parent
50163a9faf
commit
f23ae97e30
2 changed files with 31 additions and 20 deletions
|
|
@ -363,16 +363,18 @@ main (int argc, const char *argv[])
|
|||
|
||||
parse_args (argc, argv, &args);
|
||||
|
||||
if (args.num_filenames < 1)
|
||||
usage (argv[0]);
|
||||
|
||||
reports = xcalloc (args.num_filenames, sizeof (cairo_perf_report_t));
|
||||
|
||||
for (i = 0; i < args.num_filenames; i++) {
|
||||
cairo_perf_report_load (&reports[i], args.filenames[i],
|
||||
test_report_cmp_name);
|
||||
printf ("loaded: %s, %d tests\n",
|
||||
args.filenames[i], reports[i].tests_count);
|
||||
if (args.num_filenames) {
|
||||
reports = xcalloc (args.num_filenames, sizeof (cairo_perf_report_t));
|
||||
for (i = 0; i < args.num_filenames; i++) {
|
||||
cairo_perf_report_load (&reports[i], args.filenames[i],
|
||||
test_report_cmp_name);
|
||||
printf ("loaded: %s, %d tests\n",
|
||||
args.filenames[i], reports[i].tests_count);
|
||||
}
|
||||
} else {
|
||||
args.num_filenames = 1;
|
||||
reports = xcalloc (args.num_filenames, sizeof (cairo_perf_report_t));
|
||||
cairo_perf_report_load (&reports[0], NULL, test_report_cmp_name);
|
||||
}
|
||||
|
||||
cairo_perf_reports_compare (reports, args.num_filenames, &args.options);
|
||||
|
|
|
|||
|
|
@ -437,9 +437,14 @@ cairo_perf_report_load (cairo_perf_report_t *report,
|
|||
char *configuration;
|
||||
char *dot;
|
||||
char *baseName;
|
||||
const char *name;
|
||||
|
||||
configuration = xmalloc (strlen (filename) * sizeof (char) + 1);
|
||||
strcpy (configuration, filename);
|
||||
name = filename;
|
||||
if (name == NULL)
|
||||
name = "stdin";
|
||||
|
||||
configuration = xmalloc (strlen (name) * sizeof (char) + 1);
|
||||
strcpy (configuration, name);
|
||||
baseName = basename (configuration);
|
||||
report->configuration = xmalloc (strlen (baseName) * sizeof (char) + 1);
|
||||
strcpy (report->configuration, baseName);
|
||||
|
|
@ -449,16 +454,20 @@ cairo_perf_report_load (cairo_perf_report_t *report,
|
|||
if (dot)
|
||||
*dot = '\0';
|
||||
|
||||
report->name = filename;
|
||||
report->name = name;
|
||||
report->tests_size = 16;
|
||||
report->tests = xmalloc (report->tests_size * sizeof (test_report_t));
|
||||
report->tests_count = 0;
|
||||
|
||||
file = fopen (filename, "r");
|
||||
if (file == NULL) {
|
||||
fprintf (stderr, "Failed to open %s: %s\n",
|
||||
filename, strerror (errno));
|
||||
exit (1);
|
||||
if (filename == NULL) {
|
||||
file = stdin;
|
||||
} else {
|
||||
file = fopen (filename, "r");
|
||||
if (file == NULL) {
|
||||
fprintf (stderr, "Failed to open %s: %s\n",
|
||||
filename, strerror (errno));
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
|
@ -485,7 +494,8 @@ cairo_perf_report_load (cairo_perf_report_t *report,
|
|||
if (line)
|
||||
free (line);
|
||||
|
||||
fclose (file);
|
||||
if (filename != NULL)
|
||||
fclose (file);
|
||||
|
||||
cairo_perf_report_sort_and_compute_stats (report, cmp);
|
||||
|
||||
|
|
@ -497,4 +507,3 @@ cairo_perf_report_load (cairo_perf_report_t *report,
|
|||
}
|
||||
report->tests[report->tests_count].name = NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue