From 958ad397391a78ab48a22e8172abdda895cbf65c Mon Sep 17 00:00:00 2001 From: Ben Kurtovic Date: Tue, 4 Sep 2012 01:39:19 -0400 Subject: [PATCH] Processing time has been moved into EarwigBot main. --- pages/copyvios.mako | 6 +++--- toolserver/copyvios/checker.py | 14 ++++---------- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/pages/copyvios.mako b/pages/copyvios.mako index 7f26bcd..4e18c73 100644 --- a/pages/copyvios.mako +++ b/pages/copyvios.mako @@ -91,7 +91,7 @@ To save time (and money), this tool will retain the results of checks for up to 72 hours. This includes the URL of the "violated" source, but neither its content nor the content of the article. Future checks on the same page (assuming it remains unchanged) will not involve additional search queries, but a fresh comparison against the source URL will be made. If the page is modified, a new check will be run. from ${result.cache_time} (${result.cache_age} ago). Bypass the cache. % else: -
  • Results generated in ${round(result.tdiff, 3)} seconds using ${result.queries} queries.
  • +
  • Results generated in ${round(result.time, 3)} seconds using ${result.queries} queries.
  • % endif % if "EarwigCVShowDetails" in cookies and cookies["EarwigCVShowDetails"].value == "True":
  • Hide details:
  • @@ -108,9 +108,9 @@
  • Trigrams: Article: ${result.article_chain.size()} / Source: ${result.source_chain.size()} / Delta: ${result.delta_chain.size()}
  • % if result.cached: % if result.queries: -
  • Retrieved from cache in ${round(result.tdiff, 3)} seconds (originally generated in ${round(result.original_tdiff, 3)}s using ${result.queries} queries; ${round(result.original_tdiff - result.tdiff, 3)}s saved).
  • +
  • Retrieved from cache in ${round(result.time, 3)} seconds (originally generated in ${round(result.original_time, 3)}s using ${result.queries} queries; ${round(result.original_time - result.time, 3)}s saved).
  • % else: -
  • Retrieved from cache in ${round(result.tdiff, 3)} seconds (originally generated in ${round(result.original_tdiff, 3)}s; ${round(result.original_tdiff - result.tdiff, 3)}s saved).
  • +
  • Retrieved from cache in ${round(result.time, 3)} seconds (originally generated in ${round(result.original_time, 3)}s; ${round(result.original_time - result.time, 3)}s saved).
  • % endif % endif % if result.queries: diff --git a/toolserver/copyvios/checker.py b/toolserver/copyvios/checker.py index b890b01..e29e08b 100644 --- a/toolserver/copyvios/checker.py +++ b/toolserver/copyvios/checker.py @@ -30,15 +30,13 @@ def get_results(bot, site, query): mci = MarkovChainIntersection(mc1, mc2) result = CopyvioCheckResult(True, 0.67123, "http://example.com/", 7, mc1, (mc2, mci)) result.cached = False - result.tdiff = time() - tstart + result.time = time() - tstart # END TEST BLOCK return page, result def _get_url_specific_results(page, url): - t_start = time() result = page.copyvio_compare(url) result.cached = False - result.tdiff = time() - t_start return result def _get_cached_results(page, conn): @@ -46,7 +44,6 @@ def _get_cached_results(page, conn): query2 = "SELECT cache_url, cache_time, cache_queries, cache_process_time FROM cache WHERE cache_id = ? AND cache_hash = ?" pageid = page.pageid() hash = sha256(page.get()).hexdigest() - t_start = time() with conn.cursor() as cursor: cursor.execute(query1) @@ -55,12 +52,11 @@ def _get_cached_results(page, conn): if not results: return None - url, cache_time, num_queries, original_tdiff = results[0] + url, cache_time, num_queries, original_time = results[0] result = page.copyvio_compare(url) result.cached = True result.queries = num_queries - result.tdiff = time() - t_start - result.original_tdiff = original_tdiff + result.original_time = original_time result.cache_time = cache_time.strftime("%b %d, %Y %H:%M:%S UTC") result.cache_age = _format_date(cache_time) return result @@ -74,10 +70,8 @@ def _format_date(cache_time): return "{0} seconds".format(diff.seconds) def _get_fresh_results(page, conn): - t_start = time() result = page.copyvio_check(max_queries=10, max_time=45) result.cached = False - result.tdiff = time() - t_start _cache_result(page, result, conn) return result @@ -92,4 +86,4 @@ def _cache_result(page, result, conn): if cursor.fetchall(): cursor.execute(query2, (pageid,)) cursor.execute(query3, (pageid, hash, result.url, result.queries, - result.tdiff)) + result.time))