2 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "fps-tracker.h"
26 #include <base/environment-options.h>
39 const char* DALI_TEMP_UPDATE_FPS_FILE( "/tmp/dalifps.txt" );
40 } // unnamed namespace
42 FpsTracker::FpsTracker( const EnvironmentOptions& environmentOptions )
43 : mFpsTrackingSeconds( fabsf( environmentOptions.GetFrameRateLoggingFrequency() ) ),
49 FpsTracker::~FpsTracker()
51 if( mFpsTrackingSeconds > 0.f )
57 void FpsTracker::Track( float secondsFromLastFrame )
59 if( mFpsTrackingSeconds > 0.f )
61 if ( mElapsedTime < mFpsTrackingSeconds )
63 mElapsedTime += secondsFromLastFrame;
75 bool FpsTracker::Enabled() const
77 return mFpsTrackingSeconds > 0.0f;
80 void FpsTracker::OutputFPSRecord()
82 float fps = mFrameCount / mElapsedTime;
83 DALI_LOG_FPS("Frame count %.0f, elapsed time %.1fs, FPS: %.2f\n", mFrameCount, mElapsedTime, fps );
85 // Dumps out the frame rate.
86 FILE* outfile = fopen( DALI_TEMP_UPDATE_FPS_FILE, "w" );
90 snprintf(fpsString,sizeof(fpsString),"%.2f \n", fps );
91 fputs( fpsString, outfile ); // ignore the error on purpose
96 } // namespace Adaptor
98 } // namespace Internal