Skip to content

Instantly share code, notes, and snippets.

@a-poor
Created August 7, 2020 00:49
Show Gist options
  • Save a-poor/b49e8105d4cbb1c15d5b78f8b26e7484 to your computer and use it in GitHub Desktop.
Save a-poor/b49e8105d4cbb1c15d5b78f8b26e7484 to your computer and use it in GitHub Desktop.
Wrote profile results to script-profile.py.lprof
Timer unit: 1e-06 s
Total time: 5.62982 s
File: script-profile.py
Function: read_books at line 19
Line # Hits Time Per Hit % Time Line Contents
========================================================
19 @profile
20 def read_books(urls):
21 """For each url in urls,
22 load the book and count the words"""
23 # Create a place to store word counts
24 1 1.0 1.0 0.0 word_counts = {}
25 # Per book: load, count words, store counts
26 6 15.0 2.5 0.0 for title, path in urls.items():
27 5 5038674.0 1007734.8 89.5 book = get_book(path)
28 5 431378.0 86275.6 7.7 words = split_words(book)
29 5 121321.0 24264.2 2.2 counts = count_words(words)
30 5 38429.0 7685.8 0.7 word_counts[title] = counts.most_common()[:10]
31 1 0.0 0.0 0.0 return word_counts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment