void printGlobalStats(struct config* config) { pthread_mutex_lock(&stats_lock); struct timeval currentTime; gettimeofday(¤tTime, NULL); double timeDiff = currentTime.tv_sec - global_stats.last_time.tv_sec + 1e-6*(currentTime.tv_sec - global_stats.last_time.tv_sec); double rps = global_stats.requests/timeDiff; double std = getStdDev(&global_stats.response_time); double q90 = findQuantile(&global_stats.response_time, .90); double q95 = findQuantile(&global_stats.response_time, .95); double q99 = findQuantile(&global_stats.response_time, .99); //printf("%10s,%8s,%16s, %8s,%11s,%10s,%13s,%10s,%10s,%10s,%12s,%10s,%10s,%11s,%14s\n", "timeDiff", "rps", "requests", "gets", "sets", "hits", "misses", "avg_lat", "90th", "95th", "99th", "std", "min", "max", "avgGetSize"); printf("%10f, %9.1f, %10d, %10d, %10d, %10d, %10d, %10f, %10f, %10f, %10f, %10f, %10f, %10f, %10f\n", timeDiff, rps, global_stats.requests, global_stats.gets, global_stats.sets, global_stats.hits, global_stats.misses, 1000*getAvg(&global_stats.response_time), 1000*q90, 1000*q95, 1000*q99, 1000*std, 1000*global_stats.response_time.min, 1000*global_stats.response_time.max, getAvg(&global_stats.get_size)); /* printf("Outstanding requests per worker:\n"); for(i=0; i<config->n_workers; i++){ printf("%d ", config->workers[i]->n_requests); } printf("\n"); */ //Reset stats memset(&global_stats, 0, sizeof(struct memcached_stats)); global_stats.response_time.min = 1000000; global_stats.last_time = currentTime; checkExit(config); pthread_mutex_unlock(&stats_lock); }//End printGlobalStats()
vector<double>* GaussianEstimator::estimatedWeight_LessThan_EqualTo_GreaterThan_Value(double value) { double equalToWeight = probabilityDensity(value) * this->m_weightSum; double stdDev = getStdDev(); double lessThanWeight = stdDev > 0.0 ? normalProbability((value - getMean()) / stdDev) * this->m_weightSum - equalToWeight : (value < getMean() ? this->m_weightSum - equalToWeight : 0.0); double greaterThanWeight = this->m_weightSum - equalToWeight - lessThanWeight; if (greaterThanWeight < 0.0) { greaterThanWeight = 0.0; } vector<double>* retVec = new vector<double>{lessThanWeight, equalToWeight, greaterThanWeight}; return retVec; }
double GaussianEstimator::probabilityDensity(double value) { if (m_weightSum > 0.0) { double stdDev = getStdDev(); if (stdDev > 0.0) { double diff = value - m_mean; return (1.0 / (NORMAL_CONSTANT * stdDev)) * exp(-(diff * diff / (2.0 * stdDev * stdDev))); } return (value == m_mean) ? 1.0 : 0.0; } return 0.0; }
std::vector< size_t > GpuStatTimer::pruneOutliers( size_t id , cl_double multiple ) { std::vector< StatData > mean = getMean( id ); std::vector< StatData > stdDev = getStdDev( id ); std::vector< size_t > totalPrune; for( size_t s = 0; s < timerData.at( id ).size( ); ++s ) { // Look on p. 379, "The C++ Standard Library" // std::remove_if does not actually erase, it only copies elements, it returns new 'logical' end StatDataVec::iterator newEnd = std::remove_if( timerData.at( id ).at( s ).begin( ), timerData.at( id ).at( s ).end( ), PruneRange< StatData,cl_double >( mean[ s ], multiple * stdDev[ s ].doubleNanoSec ) ); StatDataVec::difference_type dist = std::distance( newEnd, timerData.at( id ).at( s ).end( ) ); if( dist != 0 ) timerData.at( id ).at( s ).erase( newEnd, timerData.at( id ).at( s ).end( ) ); totalPrune.push_back( dist ); } return totalPrune; }
void CIterationCostMode::perform() { for(auto & strategy : CConfManager::getInstance().getStrategies()) { std::clog << "--------------- " << strategy << " ---------------" << std::endl; auto algSettings = CConfManager::getInstance().getAlgParameters(strategy); for(auto & instance : instanceMap) { std::shared_ptr<IStrategy> currentAlgorithm ( m_algorithmFactory.create(strategy, instance.second.flows, instance.second.distances, algSettings ) ); m_csv.add("iterations", "bestCost", "meanCost", "deviation"); for(unsigned idx = 50; idx <= 400; idx+=50 ) { std::clog << "Computing " << idx << " iterations" << std::endl; m_stopWatch.measureExecutionTime(currentAlgorithm, static_cast<long>(idx)); auto cost = currentAlgorithm->getCost(); auto costStatsCalculator = currentAlgorithm->getCostStatsCalculator(); m_csv.add(idx, cost, costStatsCalculator.getMean(), costStatsCalculator.getStdDev()); } std::vector<std::string> splitted; boost::split(splitted,instance.first, boost::is_any_of("/")); std::string filename = strategy+"_"+splitted[splitted.size()-1]+"_cost_.csv"; std::clog << filename << std::endl; m_csv.toFile(filename); m_csv.clear(); } } }
unsigned int StatisticalTimer::pruneOutliers( sTimerID id , double multiple ) { if( clkTicks.empty( ) ) return 0; double mean = getMean( id ); double stdDev = getStdDev( id ); clkVector& clks = clkTicks.at( id ); // Look on p. 379, "The C++ Standard Library" // std::remove_if does not actually erase, it only copies elements, it returns new 'logical' end clkVector::iterator newEnd = std::remove_if( clks.begin( ), clks.end( ), PruneRange< double,unsigned long long >( mean, multiple*stdDev ) ); clkVector::difference_type dist = std::distance( newEnd, clks.end( ) ); if( dist != 0 ) clks.erase( newEnd, clks.end( ) ); assert( dist < std::numeric_limits< unsigned int >::max( ) ); return static_cast< unsigned int >( dist ); }
int report_stats(Options* inOptions, TMStats* inStats) { int retval = 0; fprintf(inOptions->mOutput, "Peak Memory Usage: %11d\n", inStats->uPeakMemory); fprintf(inOptions->mOutput, "Memory Leaked: %11d\n", inStats->uMemoryInUse); fprintf(inOptions->mOutput, "\n"); fprintf(inOptions->mOutput, "Peak Object Count: %11d\n", inStats->uPeakObjects); fprintf(inOptions->mOutput, "Objects Leaked: %11d\n", inStats->uObjectsInUse); if(0 != inOptions->mAverages && 0 != inStats->uObjectsInUse) { fprintf(inOptions->mOutput, "Average Leaked Object Size: %11.4f\n", (PRFloat64)inStats->uMemoryInUse / (PRFloat64)inStats->uObjectsInUse); } fprintf(inOptions->mOutput, "\n"); fprintf(inOptions->mOutput, "Call Total: %11d\n", inStats->uMallocs + inStats->uCallocs + inStats->uReallocs + inStats->uFrees); fprintf(inOptions->mOutput, " malloc: %11d\n", inStats->uMallocs); fprintf(inOptions->mOutput, " calloc: %11d\n", inStats->uCallocs); fprintf(inOptions->mOutput, " realloc: %11d\n", inStats->uReallocs); fprintf(inOptions->mOutput, " free: %11d\n", inStats->uFrees); fprintf(inOptions->mOutput, "\n"); fprintf(inOptions->mOutput, "Byte Total (sans free): %11d\n", inStats->uMallocSize + inStats->uCallocSize + inStats->uReallocSize); fprintf(inOptions->mOutput, " malloc: %11d\n", inStats->uMallocSize); fprintf(inOptions->mOutput, " calloc: %11d\n", inStats->uCallocSize); fprintf(inOptions->mOutput, " realloc: %11d\n", inStats->uReallocSize); fprintf(inOptions->mOutput, " free: %11d\n", inStats->uFreeSize); if(0 != inOptions->mAverages) { fprintf(inOptions->mOutput, "Byte Averages:\n"); fprintf(inOptions->mOutput, " malloc: %11.4f\n", getAverage(&inStats->mMallocSizeVar)); fprintf(inOptions->mOutput, " calloc: %11.4f\n", getAverage(&inStats->mCallocSizeVar)); fprintf(inOptions->mOutput, " realloc: %11.4f\n", getAverage(&inStats->mReallocSizeVar)); fprintf(inOptions->mOutput, " free: %11.4f\n", getAverage(&inStats->mFreeSizeVar)); } if(0 != inOptions->mDeviances) { fprintf(inOptions->mOutput, "Byte Standard Deviations:\n"); fprintf(inOptions->mOutput, " malloc: %11.4f\n", getStdDev(&inStats->mMallocSizeVar)); fprintf(inOptions->mOutput, " calloc: %11.4f\n", getStdDev(&inStats->mCallocSizeVar)); fprintf(inOptions->mOutput, " realloc: %11.4f\n", getStdDev(&inStats->mReallocSizeVar)); fprintf(inOptions->mOutput, " free: %11.4f\n", getStdDev(&inStats->mFreeSizeVar)); } fprintf(inOptions->mOutput, "\n"); fprintf(inOptions->mOutput, "Overhead Total: %11.4f\n", COST_PRINTABLE(inStats->uMallocCost) + COST_PRINTABLE(inStats->uCallocCost) + COST_PRINTABLE(inStats->uReallocCost) + COST_PRINTABLE(inStats->uFreeCost)); fprintf(inOptions->mOutput, " malloc: %11.4f\n", COST_PRINTABLE(inStats->uMallocCost)); fprintf(inOptions->mOutput, " calloc: %11.4f\n", COST_PRINTABLE(inStats->uCallocCost)); fprintf(inOptions->mOutput, " realloc: %11.4f\n", COST_PRINTABLE(inStats->uReallocCost)); fprintf(inOptions->mOutput, " free: %11.4f\n", COST_PRINTABLE(inStats->uFreeCost)); if(0 != inOptions->mAverages) { fprintf(inOptions->mOutput, "Overhead Averages:\n"); fprintf(inOptions->mOutput, " malloc: %11.4f\n", COST_PRINTABLE(getAverage(&inStats->mMallocCostVar))); fprintf(inOptions->mOutput, " calloc: %11.4f\n", COST_PRINTABLE(getAverage(&inStats->mCallocCostVar))); fprintf(inOptions->mOutput, " realloc: %11.4f\n", COST_PRINTABLE(getAverage(&inStats->mReallocCostVar))); fprintf(inOptions->mOutput, " free: %11.4f\n", COST_PRINTABLE(getAverage(&inStats->mFreeCostVar))); } if(0 != inOptions->mDeviances) { fprintf(inOptions->mOutput, "Overhead Standard Deviations:\n"); fprintf(inOptions->mOutput, " malloc: %11.4f\n", COST_PRINTABLE(getStdDev(&inStats->mMallocCostVar))); fprintf(inOptions->mOutput, " calloc: %11.4f\n", COST_PRINTABLE(getStdDev(&inStats->mCallocCostVar))); fprintf(inOptions->mOutput, " realloc: %11.4f\n", COST_PRINTABLE(getStdDev(&inStats->mReallocCostVar))); fprintf(inOptions->mOutput, " free: %11.4f\n", COST_PRINTABLE(getStdDev(&inStats->mFreeCostVar))); } fprintf(inOptions->mOutput, "\n"); if(0 != inOptions->mRunLength) { unsigned length = inStats->uMaxTicks - inStats->uMinTicks; fprintf(inOptions->mOutput, "Run Length: %11.4f\n", COST_PRINTABLE(length)); fprintf(inOptions->mOutput, "\n"); } return retval; }
void GStatsPDF::reportValue() const { Report::field("%s:v=%g:sdev=%g:s=%g:n=%lld", name, getDouble(), getStdDev(), getSpread(0.90),nData); }
void printStdDev() { std::cout << "Standard Deviation: " << getStdDev() << std::endl; }