mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
844 B
37 lines
844 B
// Copyright 2016 the V8 project authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#ifndef V8_UTILS_INL_H_
|
|
#define V8_UTILS_INL_H_
|
|
|
|
#include "src/utils.h"
|
|
|
|
#include "include/v8-platform.h"
|
|
#include "src/base/platform/time.h"
|
|
#include "src/v8.h"
|
|
|
|
namespace v8 {
|
|
namespace internal {
|
|
|
|
class TimedScope {
|
|
public:
|
|
explicit TimedScope(double* result)
|
|
: start_(TimestampMs()), result_(result) {}
|
|
|
|
~TimedScope() { *result_ = TimestampMs() - start_; }
|
|
|
|
private:
|
|
static inline double TimestampMs() {
|
|
return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() *
|
|
static_cast<double>(base::Time::kMillisecondsPerSecond);
|
|
}
|
|
|
|
double start_;
|
|
double* result_;
|
|
};
|
|
|
|
} // namespace internal
|
|
} // namespace v8
|
|
|
|
#endif // V8_UTILS_INL_H_
|
|
|