-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbenchmark.py
More file actions
26 lines (22 loc) · 859 Bytes
/
benchmark.py
File metadata and controls
26 lines (22 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from scrapy.crawler import CrawlerProcess
from scrapy.spiderloader import SpiderLoader
from scrapy.utils.project import get_project_settings
from memory_profiler import profile
import time
@profile
def benchmark(spider_list: list[str]):
settings = get_project_settings()
spider_loader = SpiderLoader(settings)
process = CrawlerProcess(get_project_settings())
for spider in spider_list:
spider = spider_loader.load(spider)
process.crawl(spider)
process.start()
start = time.perf_counter()
# spider_list = spider_loader.list()
spider_list = ['mopon', 'offch', 'takhfifan', 'digikala-products', 'digistyle-products'
# 'digikalajet-products', 'snappexpress-products', 'snappfood-products',
]
benchmark(spider_list)
end = time.perf_counter()
print(f"Execution Time: {end - start} seconds")