Diligent Engine API Reference: D:/GitHub/DiligentEngine/DiligentCore/External/Android/ndk_helper/include/perfMonitor.h Source File

Diligent Engine API Reference

perfMonitor.h
1 /*
2 * Copyright 2013 The Android Open Source Project
3 *
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
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
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.
15 */
16
17 #ifndef PERFMONITOR_H_
18 #define PERFMONITOR_H_
19
20 #include <jni.h>
21 #include <errno.h>
22 #include <time.h>
23 #include "JNIHelper.h"
24
25 namespace ndk_helper {
26
27 const int32_t kNumSamples = 100;
28
29 /******************************************************************
30 * Helper class for a performance monitoring and get current tick time
31 */
32 class PerfMonitor {
33 private:
34 float current_FPS_;
35 time_t tv_last_sec_;
36
37 double last_tick_;
38 int32_t tickindex_;
39 double ticksum_;
40 double ticklist_[kNumSamples];
41
42 double UpdateTick(double current_tick);
43
44 public:
45 PerfMonitor();
46 virtual ~PerfMonitor();
47
48 bool Update(float &fFPS);
49
50 static double GetCurrentTime() {
51 struct timeval time;
52 gettimeofday(&time, NULL);
53 double ret = time.tv_sec + time.tv_usec * 1.0 / 1000000.0;
54 return ret;
55 }
56 };
57
58 } // namespace ndkHelper
59 #endif /* PERFMONITOR_H_ */
ndk_helper
Definition: gestureDetector.h:32