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

Side by Side Diff: tools/android/device_stats_monitor/device_stats_monitor.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « third_party/zlib/google/zip_reader_unittest.cc ('k') | tools/gn/command_gyp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Dumps CPU and IO stats to a file at a regular interval. 5 // Dumps CPU and IO stats to a file at a regular interval.
6 // 6 //
7 // Output may be post processed by host to get top/iotop style information. 7 // Output may be post processed by host to get top/iotop style information.
8 8
9 #include <signal.h> 9 #include <signal.h>
10 #include <unistd.h> 10 #include <unistd.h>
(...skipping 26 matching lines...) Expand all
37 // Yes, this buffers everything in memory, so it cannot be used for extended 37 // Yes, this buffers everything in memory, so it cannot be used for extended
38 // durations without OOM. But that beats writing during the trace which 38 // durations without OOM. But that beats writing during the trace which
39 // would affect the results. 39 // would affect the results.
40 void Start(int hz) { 40 void Start(int hz) {
41 const int sample_interval = 1000000 / hz; 41 const int sample_interval = 1000000 / hz;
42 const base::FilePath io_stats_path(kIOStatsPath); 42 const base::FilePath io_stats_path(kIOStatsPath);
43 const base::FilePath cpu_stats_path(kCPUStatsPath); 43 const base::FilePath cpu_stats_path(kCPUStatsPath);
44 std::string out; 44 std::string out;
45 while (record_) { 45 while (record_) {
46 out.clear(); 46 out.clear();
47 CHECK(file_util::ReadFileToString(io_stats_path, &out)); 47 CHECK(base::ReadFileToString(io_stats_path, &out));
48 CHECK(file_util::ReadFileToString(cpu_stats_path, &out)); 48 CHECK(base::ReadFileToString(cpu_stats_path, &out));
49 samples_.push_back(out); 49 samples_.push_back(out);
50 usleep(sample_interval); 50 usleep(sample_interval);
51 } 51 }
52 } 52 }
53 53
54 // Stops recording and saves samples to file. 54 // Stops recording and saves samples to file.
55 void StopAndDumpStats() { 55 void StopAndDumpStats() {
56 record_ = false; 56 record_ = false;
57 usleep(250 * 1000); 57 usleep(250 * 1000);
58 std::ofstream out_stream; 58 std::ofstream out_stream;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 kDefaultHz; 99 kDefaultHz;
100 100
101 printf("Starting device stats monitor\n"); 101 printf("Starting device stats monitor\n");
102 g_device_stats_monitor = new DeviceStatsMonitor(args[0]); 102 g_device_stats_monitor = new DeviceStatsMonitor(args[0]);
103 signal(SIGTERM, SigTermHandler); 103 signal(SIGTERM, SigTermHandler);
104 g_device_stats_monitor->Start(hz); 104 g_device_stats_monitor->Start(hz);
105 delete g_device_stats_monitor; 105 delete g_device_stats_monitor;
106 106
107 return 0; 107 return 0;
108 } 108 }
OLDNEW
« no previous file with comments | « third_party/zlib/google/zip_reader_unittest.cc ('k') | tools/gn/command_gyp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698