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. 4 5#ifndef TRACELINE_RDTSC_H_ 6#define TRACELINE_RDTSC_H_ 7 8#include <windows.h> 9#include <powrprof.h> 10 11#include <map> 12 13#include "logging.h" 14 15class RDTSCNormalizer { 16 public: 17 RDTSCNormalizer() { } 18 ~RDTSCNormalizer() { } 19 20 void Start() { 21 LARGE_INTEGER freq, now; 22 if (QueryPerformanceFrequency(&freq) == 0) { 23 NOTREACHED(""); 24 } 25 freq_ = freq.QuadPart; 26 27 if (QueryPerformanceCounter(&now) == 0) { 28 NOTREACHED(""); 29 } 30 start_ = now.QuadPart; 31 } 32 33 // Calculate the time from start for a given processor. 34 double MsFromStart(void* procid, __int64 stamp) { 35 return (stamp - start_) / (freq_ / 1000.0); 36 } 37 38 private: 39 __int64 freq_; 40 __int64 start_; 41}; 42 43#endif // TRACELINE_RDTSC_H_ 44