OLD | NEW |
1 // Copyright (c) 2006-2008 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 <math.h> | 5 #include <math.h> |
6 #include <stdio.h> | 6 #include <stdio.h> |
7 | 7 |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/file_util.h" | 9 #include "base/file_util.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
11 #include "base/perftimer.h" | 11 #include "base/perftimer.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
| 13 #include "base/test/test_timeouts.h" |
13 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
14 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
15 #include "chrome/common/chrome_paths.h" | 16 #include "chrome/common/chrome_paths.h" |
16 #include "chrome/common/libxml_utils.h" | 17 #include "chrome/common/libxml_utils.h" |
17 #include "chrome/test/automation/autocomplete_edit_proxy.h" | 18 #include "chrome/test/automation/autocomplete_edit_proxy.h" |
18 #include "chrome/test/automation/automation_proxy.h" | 19 #include "chrome/test/automation/automation_proxy.h" |
19 #include "chrome/test/automation/browser_proxy.h" | 20 #include "chrome/test/automation/browser_proxy.h" |
20 #include "chrome/test/automation/window_proxy.h" | 21 #include "chrome/test/automation/window_proxy.h" |
21 #include "chrome/test/ui/ui_test.h" | 22 #include "chrome/test/ui/ui_test.h" |
22 | 23 |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 | 87 |
87 // Try every proper prefix of input_text. There's no use trying | 88 // Try every proper prefix of input_text. There's no use trying |
88 // input_text itself since the autocomplete results will always contain it. | 89 // input_text itself since the autocomplete results will always contain it. |
89 for (size_t i = 1; i < input_text.size(); ++i) { | 90 for (size_t i = 1; i < input_text.size(); ++i) { |
90 Matches matches; | 91 Matches matches; |
91 | 92 |
92 // We're only going to count the time elapsed waiting for autocomplete | 93 // We're only going to count the time elapsed waiting for autocomplete |
93 // matches to be returned to us. | 94 // matches to be returned to us. |
94 ASSERT_TRUE(autocomplete_edit->SetText(input_text.substr(0, i))); | 95 ASSERT_TRUE(autocomplete_edit->SetText(input_text.substr(0, i))); |
95 PerfTimer timer; | 96 PerfTimer timer; |
96 if (autocomplete_edit->WaitForQuery(action_max_timeout_ms())) { | 97 if (autocomplete_edit->WaitForQuery( |
| 98 TestTimeouts::action_max_timeout_ms())) { |
97 ASSERT_TRUE(autocomplete_edit->GetAutocompleteMatches(&matches)); | 99 ASSERT_TRUE(autocomplete_edit->GetAutocompleteMatches(&matches)); |
98 int64 time_elapsed = timer.Elapsed().InMilliseconds(); | 100 int64 time_elapsed = timer.Elapsed().InMilliseconds(); |
99 | 101 |
100 // Adjust statistic trackers. | 102 // Adjust statistic trackers. |
101 if (query_count_ == 0) | 103 if (query_count_ == 0) |
102 time_min_ = time_max_ = time_elapsed; | 104 time_min_ = time_max_ = time_elapsed; |
103 ++query_count_; | 105 ++query_count_; |
104 time_squared_ += time_elapsed * time_elapsed; | 106 time_squared_ += time_elapsed * time_elapsed; |
105 time_sum_ += time_elapsed; | 107 time_sum_ += time_elapsed; |
106 if (time_elapsed < time_min_) | 108 if (time_elapsed < time_min_) |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 wprintf(L"__om_query_count = %d\n", query_count_); | 175 wprintf(L"__om_query_count = %d\n", query_count_); |
174 wprintf(L"__om_query_timeouts = %d\n", query_timeouts_); | 176 wprintf(L"__om_query_timeouts = %d\n", query_timeouts_); |
175 wprintf(L"__om_time_per_query_avg = %d\n", mean); | 177 wprintf(L"__om_time_per_query_avg = %d\n", mean); |
176 // Use the equation stddev = sqrt(Sum(x_i^2)/N - mean^2). | 178 // Use the equation stddev = sqrt(Sum(x_i^2)/N - mean^2). |
177 wprintf(L"__om_time_per_query_stddev = %d\n", static_cast<int64>( | 179 wprintf(L"__om_time_per_query_stddev = %d\n", static_cast<int64>( |
178 sqrt(1.0 * time_squared_ / query_count_ - mean * mean))); | 180 sqrt(1.0 * time_squared_ / query_count_ - mean * mean))); |
179 wprintf(L"__om_time_per_query_max = %d\n", time_max_); | 181 wprintf(L"__om_time_per_query_max = %d\n", time_max_); |
180 wprintf(L"__om_time_per_query_min = %d\n", time_min_); | 182 wprintf(L"__om_time_per_query_min = %d\n", time_min_); |
181 wprintf(L"__om_score = %.4f\n", 100.0 * score_ / max_score_); | 183 wprintf(L"__om_score = %.4f\n", 100.0 * score_ / max_score_); |
182 } | 184 } |
OLD | NEW |