OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. | 2 * Copyright 2015 The WebRTC Project Authors. All rights reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 * practice.) | 45 * practice.) |
46 * | 46 * |
47 * <p>Caveats: | 47 * <p>Caveats: |
48 * o No provision made for zany "turbo" mode, common in the x86 world. | 48 * o No provision made for zany "turbo" mode, common in the x86 world. |
49 * o No provision made for ARM big.LITTLE; if CPU n can switch behind our | 49 * o No provision made for ARM big.LITTLE; if CPU n can switch behind our |
50 * back, we might get incorrect estimates. | 50 * back, we might get incorrect estimates. |
51 * o This is not thread-safe. To call asynchronously, create different | 51 * o This is not thread-safe. To call asynchronously, create different |
52 * CpuMonitor objects. | 52 * CpuMonitor objects. |
53 * | 53 * |
54 * <p>If we can gather enough info to generate a sensible result, | 54 * <p>If we can gather enough info to generate a sensible result, |
55 * sampleCpuUtilization returns true. It is designed to never through an | 55 * sampleCpuUtilization returns true. It is designed to never throw an |
56 * exception. | 56 * exception. |
57 * | 57 * |
58 * <p>sampleCpuUtilization should not be called too often in its present form, | 58 * <p>sampleCpuUtilization should not be called too often in its present form, |
59 * since then deltas would be small and the percent values would fluctuate and | 59 * since then deltas would be small and the percent values would fluctuate and |
60 * be unreadable. If it is desirable to call it more often than say once per | 60 * be unreadable. If it is desirable to call it more often than say once per |
61 * second, one would need to increase SAMPLE_SAVE_NUMBER and probably use | 61 * second, one would need to increase SAMPLE_SAVE_NUMBER and probably use |
62 * Queue<Integer> to avoid copying overhead. | 62 * Queue<Integer> to avoid copying overhead. |
63 * | 63 * |
64 * <p>Known problems: | 64 * <p>Known problems: |
65 * 1. Nexus 7 devices running Kitkat have a kernel which often output an | 65 * 1. Nexus 7 devices running Kitkat have a kernel which often output an |
(...skipping 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
503 } catch (FileNotFoundException e) { | 503 } catch (FileNotFoundException e) { |
504 Log.e(TAG, "Cannot open /proc/stat for reading", e); | 504 Log.e(TAG, "Cannot open /proc/stat for reading", e); |
505 return null; | 505 return null; |
506 } catch (IOException e) { | 506 } catch (IOException e) { |
507 Log.e(TAG, "Problems reading /proc/stat", e); | 507 Log.e(TAG, "Problems reading /proc/stat", e); |
508 return null; | 508 return null; |
509 } | 509 } |
510 return new ProcStat(userTime, systemTime, idleTime); | 510 return new ProcStat(userTime, systemTime, idleTime); |
511 } | 511 } |
512 } | 512 } |
OLD | NEW |