diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-08-23 14:39:20 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-08-23 14:41:10 +0100 |
commit | 6cdad1931a585e2f1a6a11c7a9a4687660037cd2 (patch) | |
tree | 94472416ab6e2c5b4a5ef32d081e662eb6b78ea8 /src/cairo-surface-observer.c | |
parent | ba1060fbbc62bd364d65787bb0c88281c67a534a (diff) | |
download | cairo-6cdad1931a585e2f1a6a11c7a9a4687660037cd2.tar.gz |
observe: Provide the sum of the elapsed time of the individual operations
We can use the elapsed time of the indiividual operations to profile the
synchronous throughput of a trace and eliminate all replay overhead. At
the cost of running the trace synchronously of course.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'src/cairo-surface-observer.c')
-rw-r--r-- | src/cairo-surface-observer.c | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/src/cairo-surface-observer.c b/src/cairo-surface-observer.c index 15190e921..3c4521fb1 100644 --- a/src/cairo-surface-observer.c +++ b/src/cairo-surface-observer.c @@ -1634,6 +1634,18 @@ replay_record (cairo_observation_t *log, assert (status == CAIRO_INT_STATUS_SUCCESS); } +static double +_cairo_observation_total_elapsed_ns (cairo_observation_t *log) +{ + double total = 0; + total += log->paint.elapsed; + total += log->mask.elapsed; + total += log->fill.elapsed; + total += log->stroke.elapsed; + total += log->glyphs.elapsed; + return total; +} + static void _cairo_observation_print (cairo_output_stream_t *stream, cairo_observation_t *log) @@ -1644,6 +1656,10 @@ _cairo_observation_print (cairo_output_stream_t *stream, script = _cairo_script_context_create_internal (stream); _cairo_script_context_attach_snapshots (script, FALSE); + total = _cairo_observation_total_elapsed_ns (log); + + _cairo_output_stream_printf (stream, "elapsed: %f\n", + total); _cairo_output_stream_printf (stream, "surfaces: %d\n", log->num_surfaces); _cairo_output_stream_printf (stream, "contexts: %d\n", @@ -1651,12 +1667,6 @@ _cairo_observation_print (cairo_output_stream_t *stream, _cairo_output_stream_printf (stream, "sources acquired: %d\n", log->num_sources_acquired); - total = 0; - total += log->paint.elapsed; - total += log->mask.elapsed; - total += log->fill.elapsed; - total += log->stroke.elapsed; - total += log->glyphs.elapsed; _cairo_output_stream_printf (stream, "paint: count %d [no-op %d], elapsed %f [%f%%]\n", log->paint.count, log->paint.noop, @@ -1790,6 +1800,21 @@ cairo_surface_observer_print (cairo_surface_t *abstract_surface, _cairo_output_stream_destroy (stream); } +double +cairo_surface_observer_elapsed (cairo_surface_t *abstract_surface) +{ + cairo_surface_observer_t *surface; + + if (unlikely (CAIRO_REFERENCE_COUNT_IS_INVALID (&abstract_surface->ref_count))) + return; + + if (! _cairo_surface_is_observer (abstract_surface)) + return; + + surface = (cairo_surface_observer_t *) abstract_surface; + return _cairo_observation_total_elapsed_ns (&surface->log); +} + void cairo_device_observer_print (cairo_device_t *abstract_device, cairo_write_func_t write_func, @@ -1810,3 +1835,18 @@ cairo_device_observer_print (cairo_device_t *abstract_device, _cairo_observation_print (stream, &device->log); _cairo_output_stream_destroy (stream); } + +double +cairo_device_observer_elapsed (cairo_device_t *abstract_device) +{ + cairo_device_observer_t *device; + + if (unlikely (CAIRO_REFERENCE_COUNT_IS_INVALID (&abstract_device->ref_count))) + return; + + if (! _cairo_device_is_observer (abstract_device)) + return; + + device = (cairo_device_observer_t *) abstract_device; + return _cairo_observation_total_elapsed_ns (&device->log); +} |