skia2/include/core/SkTime.h
commit-bot@chromium.org d0306a1593 Revert of Add nanosecond timer. (https://codereview.chromium.org/250243002/)
Reason for revert:
breaks EVERYTHING

Original issue's description:
> Add nanosecond timer.
>
> I've been finding it hard to get enough resolution out of our existing timers when measuring really tiny pictures.
>
> BUG=skia:2378
>
> Committed: http://code.google.com/p/skia/source/detail?r=14362

R=bsalomon@google.com, bungeman@google.com, mtklein@chromium.org
TBR=bsalomon@google.com, bungeman@google.com, mtklein@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=skia:2378

Author: mtklein@google.com

Review URL: https://codereview.chromium.org/258703002

git-svn-id: http://skia.googlecode.com/svn/trunk@14364 2bbb7eff-a529-9590-31e7-b0007b416f81
2014-04-24 20:17:24 +00:00

66 lines
1.6 KiB
C++

/*
* Copyright 2006 The Android Open Source Project
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#ifndef SkTime_DEFINED
#define SkTime_DEFINED
#include "SkTypes.h"
/** \class SkTime
Platform-implemented utilities to return time of day, and millisecond counter.
*/
class SkTime {
public:
struct DateTime {
uint16_t fYear; //!< e.g. 2005
uint8_t fMonth; //!< 1..12
uint8_t fDayOfWeek; //!< 0..6, 0==Sunday
uint8_t fDay; //!< 1..31
uint8_t fHour; //!< 0..23
uint8_t fMinute; //!< 0..59
uint8_t fSecond; //!< 0..59
};
static void GetDateTime(DateTime*);
static SkMSec GetMSecs();
};
#if defined(SK_DEBUG) && defined(SK_BUILD_FOR_WIN32)
extern SkMSec gForceTickCount;
#endif
#define SK_TIME_FACTOR 1
///////////////////////////////////////////////////////////////////////////////
class SkAutoTime {
public:
// The label is not deep-copied, so its address must remain valid for the
// lifetime of this object
SkAutoTime(const char* label = NULL, SkMSec minToDump = 0) : fLabel(label)
{
fNow = SkTime::GetMSecs();
fMinToDump = minToDump;
}
~SkAutoTime()
{
SkMSec dur = SkTime::GetMSecs() - fNow;
if (dur >= fMinToDump) {
SkDebugf("%s %d\n", fLabel ? fLabel : "", dur);
}
}
private:
const char* fLabel;
SkMSec fNow;
SkMSec fMinToDump;
};
#define SkAutoTime(...) SK_REQUIRE_LOCAL_VAR(SkAutoTime)
#endif