d2c7645bad
Add benchmark where the sequential Rust version of the word count is executed twice to demonstrate parallelism with Python threads. Also slightly simplify the benchmark functions.
19 lines
410 B
Python
19 lines
410 B
Python
from .word_count import search, search_sequential, search_sequential_allow_threads
|
|
|
|
__all__ = [
|
|
"search_py",
|
|
"search",
|
|
"search_sequential",
|
|
"search_sequential_allow_threads",
|
|
]
|
|
|
|
|
|
def search_py(contents, needle):
|
|
total = 0
|
|
for line in contents.split():
|
|
words = line.split(" ")
|
|
for word in words:
|
|
if word == needle:
|
|
total += 1
|
|
return total
|