1 /* 2 * Copyright (C) 2005 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 #define LOG_TAG "StopWatch" 18 19 #include <utils/StopWatch.h> 20 21 #include <inttypes.h> 22 23 #include <log/log.h> 24 25 namespace android { 26 StopWatch(const char * name,int clock)27StopWatch::StopWatch(const char* name, int clock) : mName(name), mClock(clock) { 28 reset(); 29 } 30 ~StopWatch()31StopWatch::~StopWatch() { 32 ALOGD("StopWatch %s (us): %" PRId64 " ", name(), ns2us(elapsedTime())); 33 } 34 name() const35const char* StopWatch::name() const { 36 return mName; 37 } 38 elapsedTime() const39nsecs_t StopWatch::elapsedTime() const { 40 return systemTime(mClock) - mStartTime; 41 } 42 reset()43void StopWatch::reset() { 44 mStartTime = systemTime(mClock); 45 } 46 47 } // namespace android 48