Chromecast: extracts Linux window creation code to a common place.
[chromium-blink-merge.git] / tools / traceline / traceline / rdtsc.h
blob7c3cb1a967612967cdeae76405e0f91debabf57e
1 // Copyright (c) 2009 The Chromium 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.
5 #ifndef TRACELINE_RDTSC_H_
6 #define TRACELINE_RDTSC_H_
8 #include <windows.h>
9 #include <powrprof.h>
11 #include <map>
13 #include "logging.h"
15 class RDTSCNormalizer {
16 public:
17 RDTSCNormalizer() { }
18 ~RDTSCNormalizer() { }
20 void Start() {
21 LARGE_INTEGER freq, now;
22 if (QueryPerformanceFrequency(&freq) == 0) {
23 NOTREACHED("");
25 freq_ = freq.QuadPart;
27 if (QueryPerformanceCounter(&now) == 0) {
28 NOTREACHED("");
30 start_ = now.QuadPart;
33 // Calculate the time from start for a given processor.
34 double MsFromStart(void* procid, __int64 stamp) {
35 return (stamp - start_) / (freq_ / 1000.0);
38 private:
39 __int64 freq_;
40 __int64 start_;
43 #endif // TRACELINE_RDTSC_H_