Merge branch 'master' of https://github.com/worklist/hifi into opencv

This commit is contained in:
Andrzej Kapolka 2013-06-21 11:35:23 -07:00
commit 0e223b90d9
4 changed files with 27 additions and 12 deletions

View file

@ -137,15 +137,8 @@ int main(int argc, const char* argv[]) {
// if we should be sending stats to Logstash send the appropriate average now
const char MIXER_LOGSTASH_METRIC_NAME[] = "audio-mixer-frame-time-usage";
// we're sending a floating point percentage with two mandatory numbers after decimal point
// that could be up to 6 bytes
const int MIXER_LOGSTASH_PACKET_BYTES = strlen(MIXER_LOGSTASH_METRIC_NAME) + 7;
char logstashPacket[MIXER_LOGSTASH_PACKET_BYTES];
float averageFrameTimePercentage = sumFrameTimePercentages / numStatCollections;
int packetBytes = sprintf(logstashPacket, "%s %.2f", MIXER_LOGSTASH_METRIC_NAME, averageFrameTimePercentage);
agentList->getAgentSocket()->send(Logstash::socket(), logstashPacket, packetBytes);
Logstash::stashValue(MIXER_LOGSTASH_METRIC_NAME, averageFrameTimePercentage);
sumFrameTimePercentages = 0.0f;
numStatCollections = 0;

View file

@ -44,14 +44,15 @@
#include <QtDebug>
#include <QFileDialog>
#include <QDesktopServices>
#include <PairingHandler.h>
#include <AgentTypes.h>
#include <PacketHeaders.h>
#include <PerfStat.h>
#include <AudioInjectionManager.h>
#include <AudioInjector.h>
#include <Logstash.h>
#include <OctalCode.h>
#include <PacketHeaders.h>
#include <PairingHandler.h>
#include <PerfStat.h>
#include "Application.h"
#include "InterfaceConfig.h"
@ -286,12 +287,17 @@ void Application::initializeGL() {
idleTimer->start(0);
if (_justStarted) {
float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime))/1000000.0;
float startupTime = (usecTimestampNow() - usecTimestamp(&_applicationStartupTime)) / 1000000.0;
_justStarted = false;
char title[50];
sprintf(title, "Interface: %4.2f seconds\n", startupTime);
printLog("%s", title);
_window->setWindowTitle(title);
const char LOGSTASH_INTERFACE_START_TIME_KEY[] = "interface-start-time";
// ask the Logstash class to record the startup time
Logstash::stashValue(LOGSTASH_INTERFACE_START_TIME_KEY, startupTime);
}
// update before the first render

View file

@ -11,6 +11,7 @@
#include <netdb.h>
#include "SharedUtil.h"
#include "AgentList.h"
#include "Logstash.h"
@ -42,4 +43,18 @@ sockaddr* Logstash::socket() {
bool Logstash::shouldSendStats() {
static bool shouldSendStats = isInEnvironment("production");
return shouldSendStats;
}
void Logstash::stashValue(const char* key, float value) {
static char logstashPacket[MAX_PACKET_SIZE];
// load up the logstash packet with the key and the passed float value
// send it to 4 decimal places
int numPacketBytes = sprintf(logstashPacket, "%s %.4f", key, value);
AgentList *agentList = AgentList::getInstance();
if (agentList) {
agentList->getAgentSocket()->send(socket(), logstashPacket, numPacketBytes);
}
}

View file

@ -18,6 +18,7 @@ class Logstash {
public:
static sockaddr* socket();
static bool shouldSendStats();
static void stashValue(const char* key, float value);
private:
static sockaddr_in logstashSocket;
};