diff --git a/plugins/GSdx/GS.cpp b/plugins/GSdx/GS.cpp index 28a14f969a..40047b37b8 100644 --- a/plugins/GSdx/GS.cpp +++ b/plugins/GSdx/GS.cpp @@ -1528,8 +1528,6 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) list packets; vector buff; - vector stats; - stats.clear(); uint8 regs[0x2000]; GSinit(); @@ -1640,11 +1638,8 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) finished = 1; } unsigned long frame_number = 0; - unsigned long total_frame_nb = 0; while(finished > 0) { - frame_number = 0; - unsigned long start = timeGetTime(); for(auto i = packets.begin(); i != packets.end(); i++) { Packet* p = *i; @@ -1686,50 +1681,17 @@ EXPORT_C GSReplay(char* lpszCmdLine, int renderer) } } - // Ensure the rendering is complete to measure correctly the time. - glFinish(); - if (finished >= 200) { ; // Nop for Nvidia Profiler } else if (finished > 90) { sleep(1); } else { - unsigned long end = timeGetTime(); - frame_number = std::max(1ul, frame_number); // avoid a potential division by 0 - - fprintf(stderr, "The %ld frames of the scene was render on %ldms\n", frame_number, end - start); - fprintf(stderr, "A means of %fms by frame\n", (float)(end - start)/(float)frame_number); - - stats.push_back((float)(end - start)); - finished--; - total_frame_nb += frame_number; } } - if (theApp.GetConfigI("linux_replay") > 1) { - // Print some nice stats - // Skip first frame (shader compilation populate the result) - // it divides by 10 the standard deviation... - float n = (float)theApp.GetConfigI("linux_replay") - 1.0f; - float mean = 0; - float sd = 0; - for (auto i = stats.begin()+1; i != stats.end(); i++) { - mean += *i; - } - mean = mean/n; - for (auto i = stats.begin()+1; i != stats.end(); i++) { - sd += pow((*i)-mean, 2); - } - sd = sqrt(sd/n); - - fprintf(stderr, "\n\nMean: %fms\n", mean); - fprintf(stderr, "Standard deviation: %fms\n", sd); - fprintf(stderr, "Mean by frame: %fms (%ffps)\n", mean/(float)frame_number, 1000.0f*frame_number/mean); - fprintf(stderr, "Standard deviation by frame: %fms\n", sd/(float)frame_number); - } #ifdef ENABLE_OGL_DEBUG_MEM_BW - total_frame_nb *= 1024; + unsigned long total_frame_nb = std::max(1ul, frame_number) << 10; fprintf(stderr, "memory bandwith. T: %f KB/f. V: %f KB/f. U: %f KB/f\n", (float)g_real_texture_upload_byte/(float)total_frame_nb, (float)g_vertex_upload_byte/(float)total_frame_nb, diff --git a/plugins/GSdx/GSDeviceOGL.cpp b/plugins/GSdx/GSDeviceOGL.cpp index 86f27ead85..70c0050011 100644 --- a/plugins/GSdx/GSDeviceOGL.cpp +++ b/plugins/GSdx/GSDeviceOGL.cpp @@ -159,34 +159,41 @@ void GSDeviceOGL::GenerateProfilerData() uint64 time_start; uint64 time_end; + std::vector times; + double ms = 0.000001; - uint64 min_time = 0xFFFFFFFFFFFFFFFFull; - uint64 max_time = 0; - uint64 total = 0; + float replay = (float)(theApp.GetConfigI("linux_replay")); + int first_query = (float)m_profiler.last_query / replay; - glGetQueryObjectui64v(m_profiler.timer_query[0], GL_QUERY_RESULT, &time_start); - for (uint32 q = 1; q < m_profiler.last_query; q++) { + glGetQueryObjectui64v(m_profiler.timer_query[first_query], GL_QUERY_RESULT, &time_start); + for (uint32 q = first_query + 1; q < m_profiler.last_query; q++) { glGetQueryObjectui64v(m_profiler.timer_query[q], GL_QUERY_RESULT, &time_end); uint64 t = time_end - time_start; - - min_time = std::min(t, min_time); - max_time = std::max(t, max_time); - total += t; + times.push_back((double)t * ms); time_start = time_end; } glDeleteQueries(1 << 16, m_profiler.timer_query); - // FIXME remove 1/linux_replay frame info - // Add fps, deviation - // remove glFinish + double frames = times.size(); + double mean = 0.0; + double sd = 0.0; - double ms = 0.000001; - fprintf(stderr, "\nGenerateProfilerData:\n"); - fprintf(stderr, "Min %f\n", (double)min_time * ms); - fprintf(stderr, "Mean %f\n", (double)total/(double)m_profiler.last_query * ms); - fprintf(stderr, "Max %f\n", (double)max_time * ms); + auto minmax_time = std::minmax_element(times.begin(), times.end()); + + for (auto t : times) mean += t; + mean = mean / frames; + + for (auto t : times) sd += pow(t-mean, 2); + sd = sqrt(sd / frames); + + fprintf(stderr, "\nPerformance Profile for %.0f frames:\n", frames); + fprintf(stderr, "Min %4.2f ms\t(%4.2f fps)\n", *minmax_time.first, 1000.0 / *minmax_time.first); + fprintf(stderr, "Mean %4.2f ms\t(%4.2f fps)\n", mean, 1000.0 / mean); + fprintf(stderr, "Max %4.2f ms\t(%4.2f fps)\n", *minmax_time.second, 1000.0 / *minmax_time.second); + fprintf(stderr, "SD %4.2f ms\t(%4.2f fps)\n", sd, 1000.0 / sd); + fprintf(stderr, "\n"); } GSTexture* GSDeviceOGL::CreateSurface(int type, int w, int h, bool msaa, int fmt)