1cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project/*
2cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project * Copyright (C) 2005 The Android Open Source Project
3cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project *
4cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project * Licensed under the Apache License, Version 2.0 (the "License");
5cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project * you may not use this file except in compliance with the License.
6cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project * You may obtain a copy of the License at
7cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project *
8cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project *      http://www.apache.org/licenses/LICENSE-2.0
9cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project *
10cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project * Unless required by applicable law or agreed to in writing, software
11cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project * distributed under the License is distributed on an "AS IS" BASIS,
12cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project * See the License for the specific language governing permissions and
14cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project * limitations under the License.
15cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project */
16cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
17cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project#ifndef ANDROID_STOPWATCH_H
18cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project#define ANDROID_STOPWATCH_H
19cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
20cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project#include <stdint.h>
21cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project#include <sys/types.h>
22cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
23cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project#include <utils/Timers.h>
24cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
25cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project// ---------------------------------------------------------------------------
26cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
27cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Projectnamespace android {
28cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
29cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Projectclass StopWatch
30cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project{
31cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Projectpublic:
32cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project        StopWatch(  const char *name,
33cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project                    int clock = SYSTEM_TIME_MONOTONIC,
34cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project                    uint32_t flags = 0);
35cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project        ~StopWatch();
36cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
37cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project        const char* name() const;
38cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project        nsecs_t     lap();
39cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project        nsecs_t     elapsedTime() const;
4066db68948c83f1940fa66d76d28208b49bed7815Jeff Brown
4166db68948c83f1940fa66d76d28208b49bed7815Jeff Brown        void        reset();
42cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
43cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Projectprivate:
44cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project    const char*     mName;
45cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project    int             mClock;
46cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project    uint32_t        mFlags;
47cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
48cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project    struct lap_t {
49cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project        nsecs_t     soFar;
50cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project        nsecs_t     thisLap;
51cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project    };
52cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
53cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project    nsecs_t         mStartTime;
54cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project    lap_t           mLaps[8];
55cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project    int             mNumLaps;
56cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project};
57cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
58cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
59cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project}; // namespace android
60cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
61cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
62cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project// ---------------------------------------------------------------------------
63cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project
64cbb1011c95e0c25c29e40e203a6a31bccd029da3The Android Open Source Project#endif // ANDROID_STOPWATCH_H
65