OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 // Helper program to analyze the time that Chrome's renderers spend in system | 5 // Helper program to analyze the time that Chrome's renderers spend in system |
6 // calls. Start Chrome like this: | 6 // calls. Start Chrome like this: |
7 // | 7 // |
8 // SECCOMP_SANDBOX_DEBUGGING=1 chrome --enable-seccomp-sandbox 2>&1 | timestats | 8 // SECCOMP_SANDBOX_DEBUGGING=1 chrome --enable-seccomp-sandbox 2>&1 | timestats |
9 // | 9 // |
10 // The program prints CPU time (0-100%) spent within system calls. This gives | 10 // The program prints CPU time (0-100%) spent within system calls. This gives |
11 // a general idea of where it is worthwhile to spend effort optimizing Chrome. | 11 // a general idea of where it is worthwhile to spend effort optimizing Chrome. |
12 // | 12 // |
13 // Caveats: | 13 // Caveats: |
14 // - there currently is no way to estimate what the overhead is for running | 14 // - there currently is no way to estimate what the overhead is for running |
15 // inside of the sandbox vs. running without a sandbox. | 15 // inside of the sandbox vs. running without a sandbox. |
16 // - we currently use a very simple heuristic to decide whether a system call | 16 // - we currently use a very simple heuristic to decide whether a system call |
17 // is blocking or not. Blocking system calls should not be included in the | 17 // is blocking or not. Blocking system calls should not be included in the |
18 // computations. But it is quite possible for the numbers to be somewhat | 18 // computations. But it is quite possible for the numbers to be somewhat |
19 // wrong, because the heuristic failed. | 19 // wrong, because the heuristic failed. |
20 // - in order to collect this data, we have to turn on sandbox debugging. | 20 // - in order to collect this data, we have to turn on sandbox debugging. |
21 // There is a measurable performance penalty to doing so. Production numbers | 21 // There is a measurable performance penalty to doing so. Production numbers |
22 // are strictly better than the numbers reported by this tool. | 22 // are strictly better than the numbers reported by this tool. |
23 #include <set> | 23 #include <set> |
24 #include <vector> | 24 #include <vector> |
25 | 25 |
26 #include <stdio.h> | 26 #include <stdio.h> |
| 27 #include <stdlib.h> |
27 #include <string.h> | 28 #include <string.h> |
28 #include <sys/time.h> | 29 #include <sys/time.h> |
29 #include <time.h> | 30 #include <time.h> |
30 | 31 |
31 static const int kAvgWindowSizeMs = 500; | 32 static const int kAvgWindowSizeMs = 500; |
32 static const int kPeakWindowSizeMs = 2*1000; | 33 static const int kPeakWindowSizeMs = 2*1000; |
33 | 34 |
34 // Class containing information on a single system call. Most notably, it | 35 // Class containing information on a single system call. Most notably, it |
35 // contains the time when the system call happened, and the time that it | 36 // contains the time when the system call happened, and the time that it |
36 // took to complete. | 37 // took to complete. |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
181 | 182 |
182 // Extract the name of the system call | 183 // Extract the name of the system call |
183 *colon = '\000'; | 184 *colon = '\000'; |
184 | 185 |
185 // Add the data point and update the display | 186 // Add the data point and update the display |
186 data.addData(buf, ms); | 187 data.addData(buf, ms); |
187 } | 188 } |
188 puts(""); | 189 puts(""); |
189 return 0; | 190 return 0; |
190 } | 191 } |
OLD | NEW |