Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Unified Diff: tools/traceline/traceline/rdtsc.h

Issue 20494: Import Traceline, a Windows performance trace event logger. (Closed)
Patch Set: Feedback. Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/traceline/traceline/main.cc ('k') | tools/traceline/traceline/scripts/alloc.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/traceline/traceline/rdtsc.h
diff --git a/tools/traceline/traceline/rdtsc.h b/tools/traceline/traceline/rdtsc.h
new file mode 100755
index 0000000000000000000000000000000000000000..7c3cb1a967612967cdeae76405e0f91debabf57e
--- /dev/null
+++ b/tools/traceline/traceline/rdtsc.h
@@ -0,0 +1,43 @@
+// Copyright (c) 2009 The Chromium 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 TRACELINE_RDTSC_H_
+#define TRACELINE_RDTSC_H_
+
+#include <windows.h>
+#include <powrprof.h>
+
+#include <map>
+
+#include "logging.h"
+
+class RDTSCNormalizer {
+ public:
+ RDTSCNormalizer() { }
+ ~RDTSCNormalizer() { }
+
+ void Start() {
+ LARGE_INTEGER freq, now;
+ if (QueryPerformanceFrequency(&freq) == 0) {
+ NOTREACHED("");
+ }
+ freq_ = freq.QuadPart;
+
+ if (QueryPerformanceCounter(&now) == 0) {
+ NOTREACHED("");
+ }
+ start_ = now.QuadPart;
+ }
+
+ // Calculate the time from start for a given processor.
+ double MsFromStart(void* procid, __int64 stamp) {
+ return (stamp - start_) / (freq_ / 1000.0);
+ }
+
+ private:
+ __int64 freq_;
+ __int64 start_;
+};
+
+#endif // TRACELINE_RDTSC_H_
« no previous file with comments | « tools/traceline/traceline/main.cc ('k') | tools/traceline/traceline/scripts/alloc.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698