summaryrefslogtreecommitdiffstats
path: root/chrome/renderer
diff options
context:
space:
mode:
authorbryner@chromium.org <bryner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-03 03:04:56 +0000
committerbryner@chromium.org <bryner@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-03 03:04:56 +0000
commit76734d89bfd542ead4a9cb04d75abf34e6c2508c (patch)
tree4b662eceff9487f4407987f23ce05c52b41ef302 /chrome/renderer
parentbfbc26b5c884ac5e70292cfc65b3fffe0204801f (diff)
downloadchromium_src-76734d89bfd542ead4a9cb04d75abf34e6c2508c.zip
chromium_src-76734d89bfd542ead4a9cb04d75abf34e6c2508c.tar.gz
chromium_src-76734d89bfd542ead4a9cb04d75abf34e6c2508c.tar.bz2
Reduce the clock check granularity for term feature extraction.
Usage stats show that some users are spending substantially longer than 20ms per chunk, which hurts responsiveness. This change will cause the clock to be checked more often, which should help this at the cost of a slight increase in total feature extraction time across all chunks. BUG=none TEST=PhishingTermFeatureExtractorTest Review URL: http://codereview.chromium.org/7828061 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@99521 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r--chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc2
-rw-r--r--chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc22
2 files changed, 16 insertions, 8 deletions
diff --git a/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc b/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc
index 1bcb5e8..404a0b3 100644
--- a/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc
+++ b/chrome/renderer/safe_browsing/phishing_term_feature_extractor.cc
@@ -29,7 +29,7 @@ const int PhishingTermFeatureExtractor::kMaxTimePerChunkMs = 20;
// Experimenting shows that we get a reasonable gain in performance by
// increasing this up to around 10, but there's not much benefit in
// increasing it past that.
-const int PhishingTermFeatureExtractor::kClockCheckGranularity = 10;
+const int PhishingTermFeatureExtractor::kClockCheckGranularity = 5;
// This should be longer than we expect feature extraction to take on any
// actual phishing page.
diff --git a/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc b/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc
index c1cb5b3..ee8d6ed 100644
--- a/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc
+++ b/chrome/renderer/safe_browsing/phishing_term_feature_extractor_unittest.cc
@@ -206,7 +206,7 @@ TEST_F(PhishingTermFeatureExtractorTest, Continuation) {
page_text.append(ASCIIToUTF16("two"));
// Advance the clock 15 ms every 10 words processed, 10 ms between chunks.
- // Note that this assumes kClockCheckGranularity = 10 and
+ // Note that this assumes kClockCheckGranularity = 5 and
// kMaxTimePerChunkMs = 20.
base::TimeTicks now = base::TimeTicks::Now();
EXPECT_CALL(clock_, Now())
@@ -214,14 +214,20 @@ TEST_F(PhishingTermFeatureExtractorTest, Continuation) {
.WillOnce(Return(now))
// Time check at the start of the first chunk of work.
.WillOnce(Return(now))
- // Time check after the first 10 words.
+ // Time check after the first 5 words.
+ .WillOnce(Return(now + base::TimeDelta::FromMilliseconds(7)))
+ // Time check after the next 5 words.
.WillOnce(Return(now + base::TimeDelta::FromMilliseconds(15)))
- // Time check after the next 10 words. This is over the chunk
+ // Time check after the next 5 words.
+ .WillOnce(Return(now + base::TimeDelta::FromMilliseconds(19)))
+ // Time check after the next 5 words. This is over the chunk
// time limit, so a continuation task will be posted.
.WillOnce(Return(now + base::TimeDelta::FromMilliseconds(30)))
// Time check at the start of the second chunk of work.
.WillOnce(Return(now + base::TimeDelta::FromMilliseconds(40)))
- // Time check after the next 10 words.
+ // Time check after the next 5 words.
+ .WillOnce(Return(now + base::TimeDelta::FromMilliseconds(47)))
+ // Time check after the next 5 words.
.WillOnce(Return(now + base::TimeDelta::FromMilliseconds(55)))
// A final check for the histograms.
.WillOnce(Return(now + base::TimeDelta::FromMilliseconds(56)));
@@ -247,11 +253,11 @@ TEST_F(PhishingTermFeatureExtractorTest, Continuation) {
.WillOnce(Return(now))
// Time check at the start of the first chunk of work.
.WillOnce(Return(now))
- // Time check after the first 10 words,
+ // Time check after the first 5 words,
.WillOnce(Return(now + base::TimeDelta::FromMilliseconds(300)))
// Time check at the start of the second chunk of work.
.WillOnce(Return(now + base::TimeDelta::FromMilliseconds(350)))
- // Time check after the next 10 words. This is over the limit.
+ // Time check after the next 5 words. This is over the limit.
.WillOnce(Return(now + base::TimeDelta::FromMilliseconds(600)))
// A final time check for the histograms.
.WillOnce(Return(now + base::TimeDelta::FromMilliseconds(620)));
@@ -272,7 +278,9 @@ TEST_F(PhishingTermFeatureExtractorTest, PartialExtractionTest) {
.WillOnce(Return(now))
// Time check at the start of the first chunk of work.
.WillOnce(Return(now))
- // Time check after the first 10 words. This should be greater than
+ // Time check after the first 5 words.
+ .WillOnce(Return(now + base::TimeDelta::FromMilliseconds(15)))
+ // Time check after the next 5 words. This should be greater than
// kMaxTimePerChunkMs so that we stop and schedule extraction for later.
.WillOnce(Return(now + base::TimeDelta::FromMilliseconds(30)));