1 /*
2  * Copyright 2016 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 __VTS_MEASUREMENT_H__
18 #define __VTS_MEASUREMENT_H__
19 
20 #if USE_CTIME
21 #include <time.h>
22 #else
23 #include <sys/time.h>
24 #endif
25 
26 #include <vector>
27 
28 using namespace std;
29 
30 namespace android {
31 namespace vts {
32 
33 // Class to do measurements before and after calling a target function.
34 class VtsMeasurement {
35  public:
VtsMeasurement()36   VtsMeasurement() {}
37 
38   // Starts the measurement
39   void Start();
40 
41   // Stops the measurement and returns the measured values.
42   vector<float>* Stop();
43 
44  private:
45 // data structure to keep the start time.
46 #if USE_CTIME
47   struct timeval tv_;
48 #else
49   timespec ts_;
50 #endif
51 };
52 
53 }  // namespace vts
54 }  // namespace android
55 
56 #endif
57