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

Unified Diff: tools/win/IdleWakeups/system_information_sampler.h

Issue 2356753004: IdleWakeups tool (Closed)
Patch Set: Removed TODO from stdafx.cpp and added myself to OWNERS file. Created 4 years, 3 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/win/IdleWakeups/stdafx.cpp ('k') | tools/win/IdleWakeups/system_information_sampler.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/win/IdleWakeups/system_information_sampler.h
diff --git a/tools/win/IdleWakeups/system_information_sampler.h b/tools/win/IdleWakeups/system_information_sampler.h
new file mode 100644
index 0000000000000000000000000000000000000000..49c17164d36ad48cf5b8d332121156fbffaf539d
--- /dev/null
+++ b/tools/win/IdleWakeups/system_information_sampler.h
@@ -0,0 +1,62 @@
+// Copyright 2016 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 TOOLS_WIN_IDLEWAKEUPS_SYSTEM_INFORMATION_SAMPLER_H_
+#define TOOLS_WIN_IDLEWAKEUPS_SYSTEM_INFORMATION_SAMPLER_H_
+
+#include <map>
+#include <memory>
+#include <vector>
+
+#include <windows.h>
+
+// SYSTEM_PROCESS_INFORMATION and SYSTEM_THREAD_INFORMATION structures
+// use HANDLE for the thread / process IDs.
+typedef HANDLE ThreadId;
+typedef HANDLE ProcessId;
+
+// Contains per thread data stored in each data snapshot.
+struct ThreadData {
+ ThreadId thread_id;
+ ULONG context_switches;
+};
+
+typedef std::vector<ThreadData> ThreadsVector;
+
+// Contains per process data stored in each data snapshot.
+struct ProcessData {
+ ULONGLONG cpu_time;
+ ULONGLONG working_set;
+ ThreadsVector threads;
+};
+
+typedef std::map<ProcessId, ProcessData> ProcessDataMap;
+
+struct ProcessDataSnapshot {
+ ProcessDataMap processes;
+ double timestamp;
+};
+
+class SystemInformationSampler {
+ public:
+ SystemInformationSampler(const wchar_t* process_name);
+ ~SystemInformationSampler();
+
+ std::unique_ptr<ProcessDataSnapshot> TakeSnapshot();
+
+ const wchar_t* target_process_name_filter() const {
+ return target_process_name_;
+ }
+
+ private:
+ wchar_t target_process_name_[256] = {};
+ LARGE_INTEGER perf_frequency_;
+ LARGE_INTEGER initial_counter_;
+ size_t previous_buffer_size_ = 0;
+
+ SystemInformationSampler& operator=(const SystemInformationSampler&) = delete;
+ SystemInformationSampler(const SystemInformationSampler&) = delete;
+};
+
+#endif // TOOLS_WIN_IDLEWAKEUPS_SYSTEM_INFORMATION_SAMPLER_H_
« no previous file with comments | « tools/win/IdleWakeups/stdafx.cpp ('k') | tools/win/IdleWakeups/system_information_sampler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698