Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/wolfpld/tracy.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBartosz Taudul <wolf.pld@gmail.com>2019-08-04 02:37:04 +0300
committerBartosz Taudul <wolf.pld@gmail.com>2019-08-04 02:40:11 +0300
commite87b8d455eaaa9582dea042fe418e41688abad76 (patch)
treebc490d6fba5e39b1adf62e31014947789a9b69d7 /server/TracyView.cpp
parent8953a2652ee4031943c694e6f98450f9793fb82f (diff)
Use Theil estimator randomized approximation.
Diffstat (limited to 'server/TracyView.cpp')
-rw-r--r--server/TracyView.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/server/TracyView.cpp b/server/TracyView.cpp
index c1b3c681..9a4fe24d 100644
--- a/server/TracyView.cpp
+++ b/server/TracyView.cpp
@@ -13,6 +13,7 @@
#include <math.h>
#include <mutex>
#include <numeric>
+#include <random>
#include <stddef.h>
#include <stdlib.h>
#include <time.h>
@@ -5294,31 +5295,34 @@ void View::DrawOptions()
if( ImGui::Button( "Auto" ) )
#endif
{
- double gsum = 0;
size_t lastidx = 0;
- for( size_t j=0; j<timeline.size(); j++ )
+ for( size_t j=timeline.size()-1; j > 0; j-- )
{
if( timeline[j]->gpuEnd >= 0 )
{
lastidx = j;
- gsum += timeline[j]->gpuStart - timeline[j]->cpuStart;
+ break;
}
}
- if( lastidx > 0 )
+
+ enum { NumSlopes = 10000 };
+ std::random_device rd;
+ std::default_random_engine gen( rd() );
+ std::uniform_int_distribution<size_t> dist( 0, lastidx - 1 );
+ float slopes[NumSlopes];
+ size_t idx = 0;
+ do
{
- const double cavg = ( timeline[lastidx]->cpuStart + timeline.front()->cpuStart ) * 0.5;
- const double gavg = gsum / double( lastidx );
- double cov = 0;
- double var = 0;
- for( size_t j=0; j<lastidx; j++ )
+ const auto p0 = dist( gen );
+ const auto p1 = dist( gen );
+ if( p0 != p1 )
{
- const auto csub = timeline[j]->cpuStart - cavg;
- cov += csub * ( timeline[j]->gpuStart - timeline[j]->cpuStart - gavg );
- var += csub * csub;
+ slopes[idx++] = float( 1.0 - double( timeline[p1]->gpuStart - timeline[p0]->gpuStart ) / double( timeline[p1]->cpuStart - timeline[p0]->cpuStart ) );
}
- const double beta = cov / var;
- drift = int( 1000000000 * -beta );
}
+ while( idx < NumSlopes );
+ std::sort( slopes, slopes+NumSlopes );
+ drift = int( 1000000000 * -slopes[NumSlopes/2] );
}
}
ImGui::TreePop();