OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "remoting/host/capture_scheduler.h" | 5 #include "remoting/host/capture_scheduler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/sys_info.h" | 10 #include "base/sys_info.h" |
(...skipping 27 matching lines...) Expand all Loading... | |
38 | 38 |
39 CaptureScheduler::~CaptureScheduler() { | 39 CaptureScheduler::~CaptureScheduler() { |
40 } | 40 } |
41 | 41 |
42 base::TimeDelta CaptureScheduler::NextCaptureDelay() { | 42 base::TimeDelta CaptureScheduler::NextCaptureDelay() { |
43 // Delay by an amount chosen such that if capture and encode times | 43 // Delay by an amount chosen such that if capture and encode times |
44 // continue to follow the averages, then we'll consume the target | 44 // continue to follow the averages, then we'll consume the target |
45 // fraction of CPU across all cores. | 45 // fraction of CPU across all cores. |
46 double delay = | 46 double delay = |
47 (capture_time_.Average() + encode_time_.Average()) / | 47 (capture_time_.Average() + encode_time_.Average()) / |
48 (kRecordingCpuConsumption * num_of_processors_); | 48 (kRecordingCpuConsumption * num_of_processors_); |
alexeypa (please no reviews)
2013/03/18 19:39:39
nit: Unrelated to this CL but I think this formula
Wez
2013/03/19 23:23:14
Yes, we should review our scheduling. There are s
| |
49 | 49 |
50 if (delay < kMinimumRecordingDelay) | 50 if (delay < kMinimumRecordingDelay) |
51 return base::TimeDelta::FromMilliseconds(kMinimumRecordingDelay); | 51 return base::TimeDelta::FromMilliseconds(kMinimumRecordingDelay); |
52 return base::TimeDelta::FromMilliseconds(delay); | 52 return base::TimeDelta::FromMilliseconds(delay); |
53 } | 53 } |
54 | 54 |
55 void CaptureScheduler::RecordCaptureTime(base::TimeDelta capture_time) { | 55 void CaptureScheduler::RecordCaptureTime(base::TimeDelta capture_time) { |
56 capture_time_.Record(capture_time.InMilliseconds()); | 56 capture_time_.Record(capture_time.InMilliseconds()); |
57 } | 57 } |
58 | 58 |
59 void CaptureScheduler::RecordEncodeTime(base::TimeDelta encode_time) { | 59 void CaptureScheduler::RecordEncodeTime(base::TimeDelta encode_time) { |
60 encode_time_.Record(encode_time.InMilliseconds()); | 60 encode_time_.Record(encode_time.InMilliseconds()); |
61 } | 61 } |
62 | 62 |
63 void CaptureScheduler::SetNumOfProcessorsForTest(int num_of_processors) { | |
64 num_of_processors_ = num_of_processors; | |
65 } | |
66 | |
63 } // namespace remoting | 67 } // namespace remoting |
OLD | NEW |