1// Copyright 2016 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef V8_UTILS_INL_H_
6#define V8_UTILS_INL_H_
7
8#include "src/utils.h"
9
10#include "include/v8-platform.h"
11#include "src/base/platform/time.h"
12#include "src/v8.h"
13
14namespace v8 {
15namespace internal {
16
17class TimedScope {
18 public:
19  explicit TimedScope(double* result)
20      : start_(TimestampMs()), result_(result) {}
21
22  ~TimedScope() { *result_ = TimestampMs() - start_; }
23
24 private:
25  static inline double TimestampMs() {
26    return V8::GetCurrentPlatform()->MonotonicallyIncreasingTime() *
27           static_cast<double>(base::Time::kMillisecondsPerSecond);
28  }
29
30  double start_;
31  double* result_;
32};
33
34}  // namespace internal
35}  // namespace v8
36
37#endif  // V8_UTILS_INL_H_
38