/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
// INTERNAL INCLUDES
#include <base/environment-options.h>
+#include <base/time-service.h>
namespace Dali
{
namespace Adaptor
{
+namespace
+{
+const unsigned int NANOSECONDS_PER_MICROSECOND = 1000u;
+const float MICROSECONDS_TO_SECOND = 1e-6;
+} // unnamed namespace
+
PerformanceServer::PerformanceServer( AdaptorInternalServices& adaptorServices,
const EnvironmentOptions& environmentOptions)
-:mPlatformAbstraction( adaptorServices.GetPlatformAbstractionInterface() ),
- mEnvironmentOptions( environmentOptions ),
- mKernelTrace( adaptorServices.GetKernelTraceInterface() ),
- mStatContextManager( *this ),
- mStatisticsLogBitmask( 0 ),
- mLoggingEnabled( false ),
- mLogFunctionInstalled( false )
+: mEnvironmentOptions( environmentOptions ),
+ mKernelTrace( adaptorServices.GetKernelTraceInterface() ),
+ mSystemTrace( adaptorServices.GetSystemTraceInterface() ),
+ mLogMutex(),
+#if defined(NETWORK_LOGGING_ENABLED)
+ mNetworkServer( adaptorServices, environmentOptions ),
+ mNetworkControlEnabled( mEnvironmentOptions.GetNetworkControlMode()),
+#endif
+ mStatContextManager( *this ),
+ mStatisticsLogBitmask( 0 ),
+ mPerformanceOutputBitmask( 0 ),
+ mLoggingEnabled( false ),
+ mLogFunctionInstalled( false )
{
SetLogging( mEnvironmentOptions.GetPerformanceStatsLoggingOptions(),
mEnvironmentOptions.GetPerformanceTimeStampOutput(),
mEnvironmentOptions.GetPerformanceStatsLoggingFrequency());
+
+#if defined(NETWORK_LOGGING_ENABLED)
+ if( mNetworkControlEnabled )
+ {
+ mLoggingEnabled = true;
+ mNetworkServer.Start();
+ }
+#endif
}
PerformanceServer::~PerformanceServer()
{
+#if defined(NETWORK_LOGGING_ENABLED)
+ if( mNetworkControlEnabled )
+ {
+ mNetworkServer.Stop();
+ }
+#endif
+
if( mLogFunctionInstalled )
{
mEnvironmentOptions.UnInstallLogFunction();
unsigned int timeStampOutput,
unsigned int logFrequency )
{
- if( ( statisticsLogOptions == 0) && ( timeStampOutput == 0 ))
- {
- mLoggingEnabled = false;
- return;
- }
-
mStatisticsLogBitmask = statisticsLogOptions;
mPerformanceOutputBitmask = timeStampOutput;
mStatContextManager.SetLoggingLevel( mStatisticsLogBitmask, logFrequency);
- mLoggingEnabled = true;
+ if( ( mStatisticsLogBitmask == 0) && ( mPerformanceOutputBitmask == 0 ))
+ {
+ mLoggingEnabled = false;
+ }
+ else
+ {
+ mLoggingEnabled = true;
+ }
}
void PerformanceServer::SetLoggingFrequency( unsigned int logFrequency, ContextId contextId )
return;
}
- // This is only called from main event thread, but may overlap with internal AddMarker calls
- // from other threads ( update, render etc).
- boost::mutex::scoped_lock sharedDatalock( mDataMutex );
-
// Get the time stamp
- unsigned int seconds = 0;
- unsigned int microseconds = 0;
- mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds );
+ uint64_t timeStamp = 0;
+ TimeService::GetNanoseconds( timeStamp );
+ timeStamp /= NANOSECONDS_PER_MICROSECOND; // Convert to microseconds
// Create a marker
- PerformanceMarker marker( markerType, FrameTimeStamp( 0, seconds, microseconds ) );
+ PerformanceMarker marker( markerType, FrameTimeStamp( 0, timeStamp ) );
// get the marker description for this context, e.g SIZE_NEGOTIATION_START
const char* const description = mStatContextManager.GetMarkerDescription( markerType, contextId );
// Add custom marker to statistics context manager
mStatContextManager.AddCustomMarker( marker, contextId );
-
}
void PerformanceServer::AddMarker( MarkerType markerType )
return;
}
- // AddMarker can be called from multiple threads, to avoid problems
- // with updating contexts and the kernel trace, lock here.
- boost::mutex::scoped_lock sharedDatalock( mDataMutex );
-
if( markerType == VSYNC )
{
// make sure log function is installed, note this will be called only from v-sync thread
}
// Get the time
- unsigned int seconds = 0;
- unsigned int microseconds = 0;
- mPlatformAbstraction.GetTimeMicroseconds( seconds, microseconds );
+ uint64_t timeStamp = 0;
+ TimeService::GetNanoseconds( timeStamp );
+ timeStamp /= NANOSECONDS_PER_MICROSECOND; // Convert to microseconds
// Create a marker
- PerformanceMarker marker( markerType, FrameTimeStamp( 0, seconds, microseconds ) );
+ PerformanceMarker marker( markerType, FrameTimeStamp( 0, timeStamp ) );
// log it
LogMarker(marker, marker.GetName() );
void PerformanceServer::LogMarker( const PerformanceMarker& marker, const char* const description )
{
-
-
+#if defined(NETWORK_LOGGING_ENABLED)
+ // log to the network ( this is thread safe )
+ if( mNetworkControlEnabled )
+ {
+ mNetworkServer.TransmitMarker( marker, description );
+ }
+#endif
// log to kernel trace
if( mPerformanceOutputBitmask & OUTPUT_KERNEL_TRACE )
{
- // name will be something like UPDATE_START or UPDATE_END
- mKernelTrace.Trace( description );
+ // Kernel tracing implementation may not be thread safe
+ Mutex::ScopedLock lock( mLogMutex );
+ // description will be something like UPDATE_START or UPDATE_END
+ mKernelTrace.Trace( marker, description );
}
- // log to Dali log
+ // log to system trace
+ if( mPerformanceOutputBitmask & OUTPUT_SYSTEM_TRACE )
+ {
+ // System tracing implementation may not be thread safe
+ Mutex::ScopedLock lock( mLogMutex );
+
+ mSystemTrace.Trace( marker, description );
+ }
+
+ // log to Dali log ( this is thread safe )
if ( mPerformanceOutputBitmask & OUTPUT_DALI_LOG )
{
Integration::Log::LogMessage( Dali::Integration::Log::DebugInfo,
- "%d.%06d (seconds), %s\n",
- marker.GetTimeStamp().seconds,
- marker.GetTimeStamp().microseconds,
+ "%.6f (seconds), %s\n",
+ (float)( marker.GetTimeStamp().microseconds * MICROSECONDS_TO_SECOND ),
description);
+
}
}