Addressed issues found by Google code lint.
Fixed: - Removed trailing whitespace. - Removed out of date TODO's. - Added #include<algorithm> to DataManager.cpp - Reordered includes to include C system headers before C++ system headers. - Added username to TODO's - Renamed include guards to use full project name as prefix. - Made methods and parameters const where possible. - Made UDPSocket constructor explicit. Won't Fix: - snprintf is introduced in C++11. - Trailing comments at the end of namespace & header guards - Did not re-inlude headers already included by the matching XPC header. - localtime is fine since X-Plane is not multithreaded at all on the plugin side. - Linter confuses #elif with parens as a function call. - namespace indentation
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
#include "XPLMDataAccess.h"
|
#include "XPLMDataAccess.h"
|
||||||
#include "XPLMGraphics.h"
|
#include "XPLMGraphics.h"
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -738,7 +739,6 @@ namespace XPC
|
|||||||
Set(DREF_LocalY, local[1], aircraft);
|
Set(DREF_LocalY, local[1], aircraft);
|
||||||
Set(DREF_LocalZ, local[2], aircraft);
|
Set(DREF_LocalZ, local[2], aircraft);
|
||||||
// If the sim is unpaused, this will override the above settings.
|
// If the sim is unpaused, this will override the above settings.
|
||||||
// TODO: Are these setable when paused? Are these necessary?
|
|
||||||
Set(DREF_Latitude, (double)pos[0], aircraft);
|
Set(DREF_Latitude, (double)pos[0], aircraft);
|
||||||
Set(DREF_Longitude, (double)pos[1], aircraft);
|
Set(DREF_Longitude, (double)pos[1], aircraft);
|
||||||
Set(DREF_Elevation, (double)pos[2], aircraft);
|
Set(DREF_Elevation, (double)pos[2], aircraft);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||||
#ifndef XPC_DATAMANAGER_H
|
#ifndef XPCPLUGIN_DATAMANAGER_H_
|
||||||
#define XPC_DATAMANAGER_H
|
#define XPCPLUGIN_DATAMANAGER_H_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||||
#ifndef XPC_DRAWING_H
|
#ifndef XPCPLUGIN_DRAWING_H_
|
||||||
#define XPC_DRAWING_H
|
#define XPCPLUGIN_DRAWING_H_
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
|
||||||
|
|||||||
@@ -4,10 +4,11 @@
|
|||||||
|
|
||||||
#include "XPLMUtilities.h"
|
#include "XPLMUtilities.h"
|
||||||
|
|
||||||
#include <chrono>
|
|
||||||
#include <cstdarg>
|
#include <cstdarg>
|
||||||
#include <cstdio>
|
#include <cstdio>
|
||||||
#include <ctime>
|
#include <ctime>
|
||||||
|
|
||||||
|
#include <chrono>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||||
#ifndef XPC_LOG_H
|
#ifndef XPCPLUGIN_LOG_H_
|
||||||
#define XPC_LOG_H
|
#define XPCPLUGIN_LOG_H_
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
// LOG_VERBOSITY determines the level of logging throughout the plugin.
|
// LOG_VERBOSITY determines the level of logging throughout the plugin.
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace XPC
|
|||||||
{
|
{
|
||||||
Message::Message() {}
|
Message::Message() {}
|
||||||
|
|
||||||
Message Message::ReadFrom(UDPSocket& sock)
|
Message Message::ReadFrom(const UDPSocket& sock)
|
||||||
{
|
{
|
||||||
Message m;
|
Message m;
|
||||||
int len = sock.Read(m.buffer, bufferSize, &m.source);
|
int len = sock.Read(m.buffer, bufferSize, &m.source);
|
||||||
@@ -19,7 +19,7 @@ namespace XPC
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long Message::GetMagicNumber()
|
unsigned long Message::GetMagicNumber() const
|
||||||
{
|
{
|
||||||
if (size < 4)
|
if (size < 4)
|
||||||
{
|
{
|
||||||
@@ -28,7 +28,7 @@ namespace XPC
|
|||||||
return *((unsigned long*)buffer);
|
return *((unsigned long*)buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Message::GetHead()
|
std::string Message::GetHead() const
|
||||||
{
|
{
|
||||||
if (size < 4)
|
if (size < 4)
|
||||||
{
|
{
|
||||||
@@ -37,7 +37,7 @@ namespace XPC
|
|||||||
return std::string((char*)buffer, 4);
|
return std::string((char*)buffer, 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
const unsigned char* Message::GetBuffer()
|
const unsigned char* Message::GetBuffer() const
|
||||||
{
|
{
|
||||||
if (size == 0)
|
if (size == 0)
|
||||||
{
|
{
|
||||||
@@ -46,17 +46,17 @@ namespace XPC
|
|||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t Message::GetSize()
|
std::size_t Message::GetSize() const
|
||||||
{
|
{
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct sockaddr Message::GetSource()
|
struct sockaddr Message::GetSource() const
|
||||||
{
|
{
|
||||||
return source;
|
return source;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Message::PrintToLog()
|
void Message::PrintToLog() const
|
||||||
{
|
{
|
||||||
#if LOG_VERBOSITY > 4
|
#if LOG_VERBOSITY > 4
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||||
#ifndef XPC_MESSAGE_H
|
#ifndef XPCPLUGIN_MESSAGE_H_
|
||||||
#define XPC_MESSAGE_H
|
#define XPCPLUGIN_MESSAGE_H_
|
||||||
|
|
||||||
#include "UDPSocket.h"
|
#include "UDPSocket.h"
|
||||||
|
|
||||||
@@ -24,25 +24,25 @@ namespace XPC
|
|||||||
/// \returns A message parsed from the data read from sock. If no
|
/// \returns A message parsed from the data read from sock. If no
|
||||||
/// data was read or an error occurs, returns a message
|
/// data was read or an error occurs, returns a message
|
||||||
/// with the size set to 0.
|
/// with the size set to 0.
|
||||||
static Message ReadFrom(UDPSocket& sock);
|
static Message ReadFrom(const UDPSocket& sock);
|
||||||
|
|
||||||
/// Gets the message header in binary form.
|
/// Gets the message header in binary form.
|
||||||
unsigned long GetMagicNumber();
|
unsigned long GetMagicNumber() const;
|
||||||
|
|
||||||
/// Gets the message header.
|
/// Gets the message header.
|
||||||
std::string GetHead();
|
std::string GetHead() const;
|
||||||
|
|
||||||
/// Gets the buffer underlying the message.
|
/// Gets the buffer underlying the message.
|
||||||
const unsigned char* GetBuffer();
|
const unsigned char* GetBuffer() const;
|
||||||
|
|
||||||
/// Gets the size of the message in bytes.
|
/// Gets the size of the message in bytes.
|
||||||
std::size_t GetSize();
|
std::size_t GetSize() const;
|
||||||
|
|
||||||
/// Gets the address this message was read from.
|
/// Gets the address this message was read from.
|
||||||
struct sockaddr GetSource();
|
struct sockaddr GetSource() const;
|
||||||
|
|
||||||
/// Prints the contents of the message to the XPC log.
|
/// Prints the contents of the message to the XPC log.
|
||||||
void PrintToLog();
|
void PrintToLog() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Message();
|
Message();
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ namespace XPC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleConn(Message& msg)
|
void MessageHandlers::HandleConn(const Message& msg)
|
||||||
{
|
{
|
||||||
const unsigned char* buffer = msg.GetBuffer();
|
const unsigned char* buffer = msg.GetBuffer();
|
||||||
|
|
||||||
@@ -173,7 +173,7 @@ namespace XPC
|
|||||||
sock->SendTo(response, 6, &connection.addr);
|
sock->SendTo(response, 6, &connection.addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleCtrl(Message& msg)
|
void MessageHandlers::HandleCtrl(const Message& msg)
|
||||||
{
|
{
|
||||||
// Update Log
|
// Update Log
|
||||||
#if LOG_VERBOSITY > 2
|
#if LOG_VERBOSITY > 2
|
||||||
@@ -252,7 +252,7 @@ namespace XPC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleData(Message& msg)
|
void MessageHandlers::HandleData(const Message& msg)
|
||||||
{
|
{
|
||||||
// Parse data
|
// Parse data
|
||||||
const unsigned char* buffer = msg.GetBuffer();
|
const unsigned char* buffer = msg.GetBuffer();
|
||||||
@@ -402,7 +402,7 @@ namespace XPC
|
|||||||
DREF dref = XPData[dataRef][j];
|
DREF dref = XPData[dataRef][j];
|
||||||
if (dref == DREF_None)
|
if (dref == DREF_None)
|
||||||
{
|
{
|
||||||
// TODO: Send single line instead!
|
// TODO(jason): Send single line instead!
|
||||||
HandleXPlaneData(msg);
|
HandleXPlaneData(msg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -415,7 +415,7 @@ namespace XPC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleDref(Message& msg)
|
void MessageHandlers::HandleDref(const Message& msg)
|
||||||
{
|
{
|
||||||
#if LOG_VERBOSITY >= 3
|
#if LOG_VERBOSITY >= 3
|
||||||
Log::FormatLine("[DREF] Request to set DREF value received (Conn %i)", connection.id);
|
Log::FormatLine("[DREF] Request to set DREF value received (Conn %i)", connection.id);
|
||||||
@@ -454,7 +454,7 @@ namespace XPC
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleGetD(Message& msg)
|
void MessageHandlers::HandleGetD(const Message& msg)
|
||||||
{
|
{
|
||||||
const unsigned char* buffer = msg.GetBuffer();
|
const unsigned char* buffer = msg.GetBuffer();
|
||||||
unsigned char drefCount = buffer[5];
|
unsigned char drefCount = buffer[5];
|
||||||
@@ -504,7 +504,7 @@ namespace XPC
|
|||||||
sock->SendTo(response, cur, &connection.addr);
|
sock->SendTo(response, cur, &connection.addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandlePosi(Message& msg)
|
void MessageHandlers::HandlePosi(const Message& msg)
|
||||||
{
|
{
|
||||||
// Update log
|
// Update log
|
||||||
#if LOG_VERBOSITY > 0
|
#if LOG_VERBOSITY > 0
|
||||||
@@ -548,7 +548,7 @@ namespace XPC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleSimu(Message& msg)
|
void MessageHandlers::HandleSimu(const Message& msg)
|
||||||
{
|
{
|
||||||
// Update log
|
// Update log
|
||||||
#if LOG_VERBOSITY > 1
|
#if LOG_VERBOSITY > 1
|
||||||
@@ -600,7 +600,7 @@ namespace XPC
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleText(Message& msg)
|
void MessageHandlers::HandleText(const Message& msg)
|
||||||
{
|
{
|
||||||
// Update Log
|
// Update Log
|
||||||
#if LOG_VERBOSITY > 0
|
#if LOG_VERBOSITY > 0
|
||||||
@@ -638,7 +638,7 @@ namespace XPC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleView(Message& msg)
|
void MessageHandlers::HandleView(const Message& msg)
|
||||||
{
|
{
|
||||||
// Update Log
|
// Update Log
|
||||||
#if LOG_VERBOSITY > 0
|
#if LOG_VERBOSITY > 0
|
||||||
@@ -658,7 +658,7 @@ namespace XPC
|
|||||||
XPLMCommandKeyStroke(type);
|
XPLMCommandKeyStroke(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleWypt(Message& msg)
|
void MessageHandlers::HandleWypt(const Message& msg)
|
||||||
{
|
{
|
||||||
// Update Log
|
// Update Log
|
||||||
#if LOG_VERBOSITY > 0
|
#if LOG_VERBOSITY > 0
|
||||||
@@ -702,7 +702,7 @@ namespace XPC
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleXPlaneData(Message& msg)
|
void MessageHandlers::HandleXPlaneData(const Message& msg)
|
||||||
{
|
{
|
||||||
#if LOG_VERBOSITY > 1
|
#if LOG_VERBOSITY > 1
|
||||||
Log::WriteLine("[MSGH] Sending raw data to X-Plane");
|
Log::WriteLine("[MSGH] Sending raw data to X-Plane");
|
||||||
@@ -714,7 +714,7 @@ namespace XPC
|
|||||||
sock->SendTo(msg.GetBuffer(), msg.GetSize(), (sockaddr*)&loopback);
|
sock->SendTo(msg.GetBuffer(), msg.GetSize(), (sockaddr*)&loopback);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessageHandlers::HandleUnknown(Message& msg)
|
void MessageHandlers::HandleUnknown(const Message& msg)
|
||||||
{
|
{
|
||||||
// UPDATE LOG
|
// UPDATE LOG
|
||||||
#if LOG_VERBOSITY > 0
|
#if LOG_VERBOSITY > 0
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||||
#ifndef XPC_MESSAGEHANDLERS_H
|
#ifndef XPCPLUGIN_MESSAGEHANDLERS_H_
|
||||||
#define XPC_MESSAGEHANDLERS_H
|
#define XPCPLUGIN_MESSAGEHANDLERS_H_
|
||||||
#include "Message.h"
|
#include "Message.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
@@ -10,7 +10,7 @@
|
|||||||
namespace XPC
|
namespace XPC
|
||||||
{
|
{
|
||||||
/// A function that handles a message.
|
/// A function that handles a message.
|
||||||
typedef void(*MessageHandler)(Message&);
|
typedef void(*MessageHandler)(const Message&);
|
||||||
|
|
||||||
/// Handles incommming messages and manages connections.
|
/// Handles incommming messages and manages connections.
|
||||||
///
|
///
|
||||||
@@ -37,18 +37,18 @@ namespace XPC
|
|||||||
static void SetSocket(UDPSocket* socket);
|
static void SetSocket(UDPSocket* socket);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static void HandleConn(Message& msg);
|
static void HandleConn(const Message& msg);
|
||||||
static void HandleCtrl(Message& msg);
|
static void HandleCtrl(const Message& msg);
|
||||||
static void HandleData(Message& msg);
|
static void HandleData(const Message& msg);
|
||||||
static void HandleDref(Message& msg);
|
static void HandleDref(const Message& msg);
|
||||||
static void HandleGetD(Message& msg);
|
static void HandleGetD(const Message& msg);
|
||||||
static void HandlePosi(Message& msg);
|
static void HandlePosi(const Message& msg);
|
||||||
static void HandleSimu(Message& msg);
|
static void HandleSimu(const Message& msg);
|
||||||
static void HandleText(Message& msg);
|
static void HandleText(const Message& msg);
|
||||||
static void HandleWypt(Message& msg);
|
static void HandleWypt(const Message& msg);
|
||||||
static void HandleView(Message& msg);
|
static void HandleView(const Message& msg);
|
||||||
static void HandleXPlaneData(Message& msg);
|
static void HandleXPlaneData(const Message& msg);
|
||||||
static void HandleUnknown(Message& msg);
|
static void HandleUnknown(const Message& msg);
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ namespace XPC
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int UDPSocket::Read(unsigned char* dst, int maxLen, sockaddr* recvAddr)
|
int UDPSocket::Read(unsigned char* dst, int maxLen, sockaddr* recvAddr) const
|
||||||
{
|
{
|
||||||
socklen_t recvaddrlen = sizeof(*recvAddr);
|
socklen_t recvaddrlen = sizeof(*recvAddr);
|
||||||
int status = 0;
|
int status = 0;
|
||||||
@@ -137,7 +137,7 @@ namespace XPC
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UDPSocket::SendTo(const unsigned char* buffer, std::size_t len, sockaddr* remote)
|
void UDPSocket::SendTo(const unsigned char* buffer, std::size_t len, sockaddr* remote) const
|
||||||
{
|
{
|
||||||
if (sendto(sock, (char*)buffer, (int)len, 0, remote, sizeof(*remote)) < 0)
|
if (sendto(sock, (char*)buffer, (int)len, 0, remote, sizeof(*remote)) < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
//Copyright (c) 2013-2015 United States Government as represented by the Administrator of the
|
||||||
//National Aeronautics and Space Administration. All Rights Reserved.
|
//National Aeronautics and Space Administration. All Rights Reserved.
|
||||||
#ifndef XPC_SOCKET_H
|
#ifndef XPCPLUGIN_SOCKET_H_
|
||||||
#define XPC_SOCKET_H
|
#define XPCPLUGIN_SOCKET_H_
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <string>
|
#include <string>
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <winsock2.h>
|
#include <winsock2.h>
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
#pragma comment(lib,"ws2_32.lib") //Winsock Library
|
#pragma comment(lib, "ws2_32.lib") //Winsock Library
|
||||||
#elif (__APPLE__ || __linux)
|
#elif (__APPLE__ || __linux)
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
@@ -34,7 +34,7 @@ namespace XPC
|
|||||||
/// specified receive port.
|
/// specified receive port.
|
||||||
///
|
///
|
||||||
/// \param recvPort The port on which this instance will receive data.
|
/// \param recvPort The port on which this instance will receive data.
|
||||||
UDPSocket(unsigned short recvPort);
|
explicit UDPSocket(unsigned short recvPort);
|
||||||
|
|
||||||
/// Closes the underlying socket for this instance.
|
/// Closes the underlying socket for this instance.
|
||||||
~UDPSocket();
|
~UDPSocket();
|
||||||
@@ -48,14 +48,14 @@ namespace XPC
|
|||||||
/// of the remote host.
|
/// of the remote host.
|
||||||
/// \returns The number of bytes read, or a negative number if
|
/// \returns The number of bytes read, or a negative number if
|
||||||
/// an error occurs.
|
/// an error occurs.
|
||||||
int Read(unsigned char* buffer, int size, sockaddr* remoteAddr);
|
int Read(unsigned char* buffer, int size, sockaddr* remoteAddr) const;
|
||||||
|
|
||||||
/// Sends data to the specified remote endpoint.
|
/// Sends data to the specified remote endpoint.
|
||||||
///
|
///
|
||||||
/// \param data The data to be sent.
|
/// \param data The data to be sent.
|
||||||
/// \param len The number of bytes to send.
|
/// \param len The number of bytes to send.
|
||||||
/// \param remote The destination socket.
|
/// \param remote The destination socket.
|
||||||
void SendTo(const unsigned char* buffer, std::size_t len, sockaddr* remote);
|
void SendTo(const unsigned char* buffer, std::size_t len, sockaddr* remote) const;
|
||||||
|
|
||||||
/// Gets a string containing the IP address and port contained in the given sockaddr.
|
/// Gets a string containing the IP address and port contained in the given sockaddr.
|
||||||
///
|
///
|
||||||
|
|||||||
@@ -75,7 +75,8 @@
|
|||||||
|
|
||||||
XPC::UDPSocket* sock = NULL;
|
XPC::UDPSocket* sock = NULL;
|
||||||
|
|
||||||
double start,lap;
|
double start;
|
||||||
|
double lap;
|
||||||
static double timeConvert = 0.0;
|
static double timeConvert = 0.0;
|
||||||
int benchmarkingSwitch = 0; // 1 = time for operations, 2 = time for op + cycle;
|
int benchmarkingSwitch = 0; // 1 = time for operations, 2 = time for op + cycle;
|
||||||
int cyclesToClear = -1; // Clear message bus every n cycles. -1 == dont clear
|
int cyclesToClear = -1; // Clear message bus every n cycles. -1 == dont clear
|
||||||
@@ -98,7 +99,7 @@ PLUGIN_API int XPluginStart(char* outName, char* outSig, char* outDesc)
|
|||||||
if ( abs(timeConvert) <= 1e-9 ) // is about 0
|
if ( abs(timeConvert) <= 1e-9 ) // is about 0
|
||||||
{
|
{
|
||||||
mach_timebase_info_data_t timeBase;
|
mach_timebase_info_data_t timeBase;
|
||||||
(void)mach_timebase_info( &timeBase );
|
(void)mach_timebase_info(&timeBase);
|
||||||
timeConvert = (double)timeBase.numer /
|
timeConvert = (double)timeBase.numer /
|
||||||
(double)timeBase.denom /
|
(double)timeBase.denom /
|
||||||
1000000000.0;
|
1000000000.0;
|
||||||
@@ -196,8 +197,8 @@ float XPCFlightLoopCallback(float inElapsedSinceLastCall,
|
|||||||
{
|
{
|
||||||
#if (__APPLE__)
|
#if (__APPLE__)
|
||||||
lap = (double)mach_absolute_time( ) * timeConvert;
|
lap = (double)mach_absolute_time( ) * timeConvert;
|
||||||
diff_t = lap-start;
|
diff_t = lap - start;
|
||||||
XPC::Log::FormatLine("[BENCH] Runtime %.6f",diff_t);
|
XPC::Log::FormatLine("[BENCH] Runtime %.6f", diff_t);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user