Skip to content

Commit

Permalink
More stats added
Browse files Browse the repository at this point in the history
  • Loading branch information
SacrificeGhuleh committed Jun 6, 2024
1 parent 2454c61 commit c860326
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions frontend/src/Timeline.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@
<dd>{fetch_count}</dd>
</dl>
{#each data as restaurant}
<br>
<div style="width: {(restaurant.elapsed / max) * 100}%;" class="timeline">
({restaurant.elapsed.toFixed(3)} s)
<strong>{restaurant.name}</strong>
</div>
<div style="width: {(restaurant.elapsed_html_request / max) * 100}%;" class="timeline">
HTML request: {restaurant.elapsed_html_request.toFixed(3)} s
</div>
<div style="width: {(restaurant.elapsed_parsing / max) * 100}%;" class="timeline">
Parsing: {restaurant.elapsed_parsing.toFixed(3)} s
</div>
{/each}
</div>

Expand Down
10 changes: 8 additions & 2 deletions lunches.py
Original file line number Diff line number Diff line change
Expand Up @@ -565,25 +565,31 @@ def collect(parser):
args['res'] = response.text
else:
args['dom'] = HTMLParser(response.text)

html_request_time = time.time() - start
start = time.time()
for item in parser(**args) or []:
if isinstance(item, Soup):
soups.append(item)
elif isinstance(item, Lunch):
lunches.append(item)
else:
raise "Unsupported item"
match_time = time.time() - start
return cleanup({
**res,
'lunches': lunches,
'soups': soups,
'elapsed': time.time() - start,
'elapsed': html_request_time + match_time,
'elapsed_html_request': html_request_time,
'elapsed_parsing': match_time,
})
except: # noqa: E722
return {
**res,
'error': traceback.format_exc(),
'elapsed': time.time() - start,
'elapsed_html_request': 0,
'elapsed_parsing': 0,
}

restaurants = [obj for _, obj in globals().items() if hasattr(obj, 'parser')]
Expand Down

0 comments on commit c860326

Please sign in to comment.