diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-09-24 16:30:57 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-09-29 03:03:51 +0100 |
commit | f23ae97e307f00a79cbf2e01f9ca20da29ea87c3 (patch) | |
tree | f035f5ff252abd05dc1251e9f0e25228a5805100 /perf/cairo-perf-report.c | |
parent | 50163a9fafa77dd1135ca5b6b03c7ec5619687c1 (diff) | |
download | cairo-f23ae97e307f00a79cbf2e01f9ca20da29ea87c3.tar.gz |
[perf] Support parsing reports from stdin
Diffstat (limited to 'perf/cairo-perf-report.c')
-rw-r--r-- | perf/cairo-perf-report.c | 29 |
1 files changed, 19 insertions, 10 deletions
diff --git a/perf/cairo-perf-report.c b/perf/cairo-perf-report.c index 1690e62a4..2029a8848 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; } - |