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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 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 TOOLS_WIN_IDLEWAKEUPS_SYSTEM_INFORMATION_SAMPLER_H_
6 #define TOOLS_WIN_IDLEWAKEUPS_SYSTEM_INFORMATION_SAMPLER_H_
7
8 #include <map>
9 #include <memory>
10 #include <vector>
11
12 #include <windows.h>
13
14 // SYSTEM_PROCESS_INFORMATION and SYSTEM_THREAD_INFORMATION structures
15 // use HANDLE for the thread / process IDs.
16 typedef HANDLE ThreadId;
17 typedef HANDLE ProcessId;
18
19 // Contains per thread data stored in each data snapshot.
20 struct ThreadData {
21 ThreadId thread_id;
22 ULONG context_switches;
23 };
24
25 typedef std::vector<ThreadData> ThreadsVector;
26
27 // Contains per process data stored in each data snapshot.
28 struct ProcessData {
29 ULONGLONG cpu_time;
30 ULONGLONG working_set;
31 ThreadsVector threads;
32 };
33
34 typedef std::map<ProcessId, ProcessData> ProcessDataMap;
35
36 struct ProcessDataSnapshot {
37 ProcessDataMap processes;
38 double timestamp;
39 };
40
41 class SystemInformationSampler {
42 public:
43 SystemInformationSampler(const wchar_t* process_name);
44 ~SystemInformationSampler();
45
46 std::unique_ptr<ProcessDataSnapshot> TakeSnapshot();
47
48 const wchar_t* target_process_name_filter() const {
49 return target_process_name_;
50 }
51
52 private:
53 wchar_t target_process_name_[256] = {};
54 LARGE_INTEGER perf_frequency_;
55 LARGE_INTEGER initial_counter_;
56 size_t previous_buffer_size_ = 0;
57
58 SystemInformationSampler& operator=(const SystemInformationSampler&) = delete;
59 SystemInformationSampler(const SystemInformationSampler&) = delete;
60 };
61
62 #endif // TOOLS_WIN_IDLEWAKEUPS_SYSTEM_INFORMATION_SAMPLER_H_
OLDNEW
« 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