From: Sam Moore Date: Tue, 17 Jun 2014 09:26:46 +0000 (+0800) Subject: Performance graphs! X-Git-Url: https://git.ucc.asn.au/?p=ipdf%2Fcode.git;a=commitdiff_plain;h=d3e941df79b54b698a5b8a1d4763346c4d6eb3d7;hp=5f8aa3cf6cb5f628c7131f2ddf710562e10ad32e Performance graphs! Amazeballs --- diff --git a/bin/ipdf b/bin/ipdf index d536a81..412cf88 100755 Binary files a/bin/ipdf and b/bin/ipdf differ diff --git a/src/Makefile b/src/Makefile index 206183f..ac23acc 100644 --- a/src/Makefile +++ b/src/Makefile @@ -39,6 +39,17 @@ single : $(BIN) double : DEF = -DREAL=1 double : $(BIN) +demo : $(BIN) ../tools/stream_plot.py + mkdir -p ../data/ + $(RM) ../data/performance.dat + ./ipdf | tee ../data/performance.dat | ../tools/stream_plot.py 2>/dev/null + +movie : $(BIN) ../tools/stream_plot.py + mkdir -p ../data/ + $(RM) ../data/performance.dat + $(RM) ../data/movie.ogv + ./ipdf | tee ../data/performance.dat | ../tools/stream_plot.py 2>/dev/null & recordmydesktop --fps 10 --on-the-fly-encoding -o ../data/movie.ogv + # The tests will compile with the default REAL definition # To change that you can run as `make DEFS="REAL=X" tests/` where X is your chosen type # But remember to make clean first. @@ -73,7 +84,6 @@ clean : $(RM) tests/*.test $(RM) tests/*.out $(RM) tests/*.err - clean_full: clean $(RM) *.*~ diff --git a/src/main.h b/src/main.h index 70997a3..0d181c5 100644 --- a/src/main.h +++ b/src/main.h @@ -74,13 +74,47 @@ inline void MainLoop(Document & doc, const Rect & bounds = Rect(0,0,1,1), const } ); + double total_cpu_time = 0; + double total_gpu_time = 0; + double total_real_time = 0; + struct timespec real_clock_start; + struct timespec real_clock_now; + struct timespec real_clock_prev; + clock_gettime(CLOCK_MONOTONIC_RAW, &real_clock_start); + real_clock_now = real_clock_start; + double frames = 0; + double data_rate = 1; // period between data output to stdout (if <= 0 there will be no output) + uint64_t data_points = 0; + setbuf(stdout, NULL); while (scr.PumpEvents()) { + real_clock_prev = real_clock_now; + ++frames; scr.Clear(); + //view.ForceBoundsDirty(); + //view.ForceBufferDirty(); + //view.ForceRenderDirty(); + view.Render(scr.ViewportWidth(), scr.ViewportHeight()); - scr.DebugFontPrintF("[CPU] Render took %lf ms (%lf FPS)\n", (scr.GetLastFrameTimeCPU())* 1000.0, 1.0/scr.GetLastFrameTimeCPU()); - scr.DebugFontPrintF("[GPU] Render took %lf ms (%lf FPS)\n", (scr.GetLastFrameTimeGPU())* 1000.0, 1.0/scr.GetLastFrameTimeGPU()); + + double cpu_frame = scr.GetLastFrameTimeCPU(); + double gpu_frame = scr.GetLastFrameTimeGPU(); + clock_gettime(CLOCK_MONOTONIC_RAW, &real_clock_now); + double real_frame = (real_clock_now.tv_sec - real_clock_prev.tv_sec) + 1e-9*(real_clock_now.tv_nsec - real_clock_prev.tv_nsec); + + + total_real_time += real_frame; total_cpu_time += cpu_frame; total_gpu_time += gpu_frame; + if (data_rate > 0 && total_real_time > data_rate*(data_points+1)) + { + printf("%lu\t%f\t%f\t%f\t%f\t%f\t%f\n", (uint64_t)frames, total_real_time, total_cpu_time, total_gpu_time, real_frame, cpu_frame, gpu_frame); + data_points++; + } + scr.DebugFontPrintF("Rendered frame %lu\n", (uint64_t)frames); + scr.DebugFontPrintF("[CPU] Render took %lf ms (%lf FPS) (total %lf s, avg FPS %lf)\n", cpu_frame*1e3, 1.0/cpu_frame, total_cpu_time,frames/total_cpu_time); + scr.DebugFontPrintF("[GPU] Render took %lf ms (%lf FPS) (total %lf s, avg FPS %lf)\n", gpu_frame*1e3, 1.0/gpu_frame, total_gpu_time, frames/total_gpu_time); + scr.DebugFontPrintF("[REALTIME] Render+Present+Cruft took %lf ms (%lf FPS) (total %lf s, avg FPS %lf)\n", real_frame*1e3, 1.0/real_frame, total_real_time,frames/total_real_time); scr.DebugFontPrintF("View bounds: %s\n", view.GetBounds().Str().c_str()); + if (view.UsingGPUTransform()) { scr.DebugFontPrint("Doing coordinate transform on the GPU.\n"); diff --git a/src/objectrenderer.cpp b/src/objectrenderer.cpp index e55dbbb..25f94a1 100644 --- a/src/objectrenderer.cpp +++ b/src/objectrenderer.cpp @@ -47,7 +47,7 @@ ObjectRenderer::CPURenderBounds::CPURenderBounds(const Rect & bounds, const View y = view_bounds.y * Real(target.h); w = view_bounds.w * Real(target.w); h = view_bounds.h * Real(target.h); - Debug("CPURenderBounds %s -> %s -> {%li,%li,%li,%li}", bounds.Str().c_str(), view_bounds.Str().c_str(), x, y, w, h); + //Debug("CPURenderBounds %s -> %s -> {%li,%li,%li,%li}", bounds.Str().c_str(), view_bounds.Str().c_str(), x, y, w, h); } /** @@ -72,6 +72,7 @@ void ObjectRenderer::PrepareBuffers(unsigned max_objects) m_indexes.reserve(max_objects); //TODO: Can probably make this smaller? Or leave it out? Do we care? // Initialise and resize the ibo (for GPU rendering) + m_ibo.Invalidate(); m_ibo.SetUsage(GraphicsBuffer::BufferUsageStaticDraw); m_ibo.SetType(GraphicsBuffer::BufferTypeIndex); m_ibo.Resize(max_objects * 2 * sizeof(uint32_t)); @@ -193,9 +194,9 @@ void CircleFilledRenderer::RenderUsingCPU(const Objects & objects, const View & int64_t centre_x = bounds.x + bounds.w / 2; int64_t centre_y = bounds.y + bounds.h / 2; - Debug("Centre is %d, %d", centre_x, centre_y); - Debug("Bounds are %d,%d,%d,%d", bounds.x, bounds.y, bounds.w, bounds.h); - Debug("Windos is %d,%d", target.w, target.h); + //Debug("Centre is %d, %d", centre_x, centre_y); + //Debug("Bounds are %d,%d,%d,%d", bounds.x, bounds.y, bounds.w, bounds.h); + //Debug("Windos is %d,%d", target.w, target.h); for (int64_t x = max(0L, bounds.x); x <= min(bounds.x+bounds.w, target.w-1); ++x) { for (int64_t y = max(0L, bounds.y); y <= min(bounds.y + bounds.h, target.h-1); ++y) diff --git a/src/screen.h b/src/screen.h index a034d2a..9666c32 100644 --- a/src/screen.h +++ b/src/screen.h @@ -62,6 +62,7 @@ namespace IPDF void RenderPixels(int x, int y, int w, int h, uint8_t * pixels) const; + // Returns the CPU time (in seconds) it took to render the last completed frame. double GetLastFrameTimeCPU() const { return m_last_frame_time / SDL_GetPerformanceFrequency(); } // Returns the GPU time (in seconds) it took to render the last completed frame. diff --git a/src/view.cpp b/src/view.cpp index 6bae54e..770ecf6 100644 --- a/src/view.cpp +++ b/src/view.cpp @@ -212,7 +212,6 @@ void View::Render(int width, int height) void View::UpdateObjBoundsVBO() { - Debug("Called"); m_objbounds_vbo.Invalidate(); m_objbounds_vbo.SetType(GraphicsBuffer::BufferTypeVertex); if (m_use_gpu_transform) @@ -258,6 +257,7 @@ void View::UpdateObjBoundsVBO() void View::PrepareRender() { // Prepare bounds vbo + m_bounds_ubo.Invalidate(); m_bounds_ubo.SetType(GraphicsBuffer::BufferTypeUniform); m_bounds_ubo.SetUsage(GraphicsBuffer::BufferUsageStreamDraw); diff --git a/src/view.h b/src/view.h index 5bfced8..ff91f46 100644 --- a/src/view.h +++ b/src/view.h @@ -37,7 +37,12 @@ namespace IPDF void ToggleGPUTransform() { m_use_gpu_transform = (!m_use_gpu_transform); m_bounds_dirty = true; m_buffer_dirty = true; } void ToggleGPURendering() { m_use_gpu_rendering = (!m_use_gpu_rendering); m_bounds_dirty = true; m_buffer_dirty = true; } - + + void ForceBoundsDirty() {m_bounds_dirty = true;} + void ForceBufferDirty() {m_buffer_dirty = true;} + void ForceRenderDirty() {m_render_dirty = true;} + + private: struct GPUObjBounds {