summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-09-24 16:30:57 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2009-09-29 03:03:51 +0100
commitf23ae97e307f00a79cbf2e01f9ca20da29ea87c3 (patch)
treef035f5ff252abd05dc1251e9f0e25228a5805100
parent50163a9fafa77dd1135ca5b6b03c7ec5619687c1 (diff)
[perf] Support parsing reports from stdin
-rw-r--r--perf/cairo-perf-compare-backends.c22
-rw-r--r--perf/cairo-perf-report.c29
2 files changed, 31 insertions, 20 deletions
diff --git a/perf/cairo-perf-compare-backends.c b/perf/cairo-perf-compare-backends.c
index 1448169b..277536e5 100644
--- a/perf/cairo-perf-compare-backends.c
+++ b/perf/cairo-perf-compare-backends.c
@@ -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);
diff --git a/perf/cairo-perf-report.c b/perf/cairo-perf-report.c
index 1690e62a..2029a884 100644
--- a/perf/cairo-perf-report.c
+++ b/perf/cairo-perf-report.c
@@ -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;
}
-