| 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_
|
|
|