remove unused PerfStats class more missing header changes

This commit is contained in:
Brad Hefta-Gaub 2014-01-10 19:47:23 -08:00
parent e55e680e66
commit 731209d8cb
9 changed files with 177 additions and 324 deletions

View file

@ -125,7 +125,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
_lookingAwayFromOrigin(true),
_lookatTargetAvatar(NULL),
_lookatIndicatorScale(1.0f),
_perfStatsOn(false),
_chatEntryOn(false),
_audio(&_audioScope, STARTUP_JITTER_SAMPLES),
_stopNetworkReceiveThread(false),
@ -3655,20 +3654,6 @@ void Application::displayStats() {
}
statsVerticalOffset += PELS_PER_LINE;
drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, (char*)voxelStats.str().c_str());
if (_perfStatsOn) {
// Get the PerfStats group details. We need to allocate and array of char* long enough to hold 1+groups
char** perfStatLinesArray = new char*[PerfStat::getGroupCount()+1];
int lines = PerfStat::DumpStats(perfStatLinesArray);
for (int line=0; line < lines; line++) {
statsVerticalOffset += PELS_PER_LINE;
drawtext(10, statsVerticalOffset, 0.10f, 0, 1.0, 0, perfStatLinesArray[line]);
delete perfStatLinesArray[line]; // we're responsible for cleanup
perfStatLinesArray[line]=NULL;
}
delete []perfStatLinesArray; // we're responsible for cleanup
}
}
void Application::renderThrustAtVoxel(const glm::vec3& thrust) {

View file

@ -452,8 +452,6 @@ private:
glm::vec3 _transmitterPickStart;
glm::vec3 _transmitterPickEnd;
bool _perfStatsOn; // Do we want to display perfStats?
ChatEntry _chatEntry; // chat entry field
bool _chatEntryOn; // Whether to show the chat entry

View file

@ -9,7 +9,11 @@
#ifndef __hifi__Logging__
#define __hifi__Logging__
#ifdef _WIN32
#include "Syssocket.h"
#else
#include <netinet/in.h>
#endif
#include <QtCore/QString>

View file

@ -13,7 +13,7 @@
#include <stdlib.h>
//#include <arpa/inet.h> // not available on windows, apparently not needed on mac
#include <ifaddrs.h>
//#include <ifaddrs.h>
#include "HifiSockAddr.h"

View file

@ -197,7 +197,7 @@ void NodeList::processBulkNodeData(const HifiSockAddr& senderAddress, unsigned c
unsigned char* startPosition = packetData;
unsigned char* currentPosition = startPosition + numBytesPacketHeader;
unsigned char packetHolder[numTotalBytes];
unsigned char* packetHolder = new unsigned char[numTotalBytes];
// we've already verified packet version for the bulk packet, so all head data in the packet is also up to date
populateTypeAndVersion(packetHolder, PACKET_TYPE_HEAD_DATA);
@ -222,6 +222,8 @@ void NodeList::processBulkNodeData(const HifiSockAddr& senderAddress, unsigned c
numTotalBytes - (currentPosition - startPosition));
}
delete[] packetHolder;
}
}

View file

@ -9,7 +9,11 @@
#ifndef __hifi__NodeList__
#define __hifi__NodeList__
#ifdef _WIN32
#include "Syssocket.h"
#else
#include <netinet/in.h>
#endif
#include <stdint.h>
#include <iterator>

View file

@ -19,90 +19,6 @@
#include "PerfStat.h"
// Static class members initialization here!
std::map<std::string,PerfStatHistory,std::less<std::string> > PerfStat::groupHistoryMap;
bool PerfStat::wantDebugOut = false;
timeval PerfStat::firstDumpTime;
bool PerfStat::firstDumpTimeSet = false;
// Constructor handles starting the timer
PerfStat::PerfStat(std::string groupName) {
this->group = groupName;
gettimeofday(&this->start,NULL);
// If this is our first ever PerfStat object, we'll also initialize this
if (!firstDumpTimeSet) {
gettimeofday(&firstDumpTime,NULL);
firstDumpTimeSet=true;
}
}
// Destructor handles recording all of our stats
PerfStat::~PerfStat() {
timeval end;
gettimeofday(&end,NULL);
double elapsed = ((end.tv_usec-start.tv_usec)/1000000.0)+(end.tv_sec-start.tv_sec);
double average = elapsed;
double totalTime = elapsed;
long int count = 1;
// check to see if this group exists in the history...
if (groupHistoryMap.find(group) == groupHistoryMap.end()) {
groupHistoryMap[group]=PerfStatHistory(group,elapsed,1);
} else {
PerfStatHistory history = groupHistoryMap[group];
history.recordTime(elapsed);
groupHistoryMap[group] = history;
average = history.getAverage();
count = history.getCount();
totalTime = history.getTotalTime();
}
if (wantDebugOut) {
qDebug("PerfStats: %s elapsed:%f average:%lf count:%ld total:%lf ut:%ld us:%ld ue:%ld t:%ld s:%ld e:%ld\n",
this->group.c_str(),elapsed,average,count,totalTime,
(long)(end.tv_usec-start.tv_usec), (long)start.tv_usec, (long)end.tv_usec,
(long)(end.tv_sec-start.tv_sec), (long)start.tv_sec, (long)end.tv_sec
);
}
};
// How many groups have we added?
int PerfStat::getGroupCount() {
return groupHistoryMap.size();
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Method: DumpStats()
// Description: Generates some lines of debug stats for all the groups of PerfStats you've created.
// Note: Caller is responsible for allocating an array of char*'s that is large enough to hold
// groupCount + 1. Caller is also responsible for deleting all this memory.
int PerfStat::DumpStats(char** array) {
// If we haven't yet set a dump time, we'll also initialize this now, but this is unlikely
if (!firstDumpTimeSet) {
gettimeofday(&firstDumpTime,NULL);
firstDumpTimeSet=true;
}
timeval now;
gettimeofday(&now,NULL);
double elapsed = ((now.tv_usec-firstDumpTime.tv_usec)/1000000.0)+(now.tv_sec-firstDumpTime.tv_sec);
array[0] = new char[MAX_PERFSTAT_DEBUG_LINE_LEN];
snprintf(array[0],MAX_PERFSTAT_DEBUG_LINE_LEN,"PerfStats:");
int lineCount=1;
// For each active performance group
for (PerfStatMapItr i = groupHistoryMap.begin(); i != groupHistoryMap.end(); i++) {
float percent = (i->second.getTotalTime()/elapsed) * 100.0;
array[lineCount] = new char[MAX_PERFSTAT_DEBUG_LINE_LEN];
snprintf(array[lineCount],MAX_PERFSTAT_DEBUG_LINE_LEN,"%s Avg: %lf Num: %ld TTime: %lf (%.2f%%)",
i->second.group.c_str(),i->second.getAverage(),i->second.getCount(),i->second.getTotalTime(),percent);
lineCount++;
}
return lineCount;
}
bool PerformanceWarning::_suppressShortTimings = false;
// Destructor handles recording all of our stats

View file

@ -27,62 +27,6 @@
#include <string>
#include <map>
class PerfStatHistory {
private:
long int count;
double totalTime;
public:
std::string group;
PerfStatHistory(): count(0), totalTime(0.0) {}
PerfStatHistory(std::string myGroup, double initialTime, long int initialCount) :
count(initialCount), totalTime(initialTime), group(myGroup) {}
void recordTime(double thisTime) {
totalTime+=thisTime;
count++;
};
double getAverage() {
return totalTime/count;
};
double getTotalTime() {
return totalTime;
};
long int getCount() {
return count;
};
// needed for map template? Maybe not.
bool operator<( const PerfStatHistory& other) const {
return group < other.group;
}
};
#define MAX_PERFSTAT_DEBUG_LINE_LEN 200
class PerfStat {
private:
static std::map<std::string,PerfStatHistory,std::less<std::string> > groupHistoryMap;
static timeval firstDumpTime;
static bool firstDumpTimeSet;
std::string group;
timeval start;
public:
PerfStat(std::string groupName);
~PerfStat();
// Format debug stats into buffer, returns number of "lines" of stats
static int DumpStats(char** array);
static int getGroupCount();
static bool wantDebugOut;
};
typedef std::map<std::string,PerfStatHistory,std::less<std::string> >::iterator PerfStatMapItr;
class PerformanceWarning {
private:
uint64_t _start;