-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
123 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Bench Compare | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
checkout_and_test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ["pypy3.9", "pypy3.10", "3.9", "3.10", "3.11", "3.12"] | ||
|
||
steps: | ||
- name: Checkout code from ${{ github.repository }} | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
cache: 'pip' | ||
|
||
- name: Install Deps | ||
run: pip install scrapy && pip install spider_rs | ||
|
||
- name: Run Bench @spider-rs/spider-rs | ||
run: python ./bench/spider.py | ||
|
||
- name: Run Bench Scrapy | ||
run: python ./bench/scrappy.py |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,4 +203,5 @@ __test__/*.js | |
/storage | ||
/bench/*.js | ||
/bench/case/**.js | ||
/bench/storage/ | ||
/bench/storage/ | ||
/bench/__pycache__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Benchmarks | ||
|
||
View the latest runs on [github](https://github.com/spider-rs/spider-py/actions/workflows/bench.yml). | ||
|
||
```sh | ||
Linux | ||
8-core CPU | ||
32 GB of RAM memory | ||
----------------------- | ||
``` | ||
|
||
Test url: `https://choosealicense.com` (small) | ||
32 pages | ||
|
||
| `libraries` | `speed` | | ||
| :-------------------------------- | :------ | | ||
| **`spider-rs: crawl 10 samples`** | `76ms` | | ||
| **`scrapy: crawl 10 samples`** | `2.5s` | | ||
|
||
Test url: `https://rsseau.fr` (medium) | ||
211 pages | ||
|
||
| `libraries` | `speed` | | ||
| :-------------------------------- | :------ | | ||
| **`spider-rs: crawl 10 samples`** | `0.5s` | | ||
| **`scrapy: crawl 10 samples`** | `72s` | | ||
|
||
```sh | ||
---------------------- | ||
mac Apple M1 Max | ||
10-core CPU | ||
64 GB of RAM memory | ||
----------------------- | ||
``` | ||
|
||
Test url: `https://choosealicense.com` (small) | ||
32 pages | ||
|
||
| `libraries` | `speed` | | ||
| :-------------------------------- | :------ | | ||
| **`spider-rs: crawl 10 samples`** | `286ms` | | ||
| **`scrapy: crawl 10 samples`** | `2.5s` | | ||
|
||
Test url: `https://rsseau.fr` (medium) | ||
211 pages | ||
|
||
| `libraries` | `speed` | | ||
| :-------------------------------- | :------ | | ||
| **`spider-rs: crawl 10 samples`** | `2.5s` | | ||
| **`scrapy: crawl 10 samples`** | `10s` | | ||
|
||
The performance scales the larger the website and if throttling is needed. Linux benchmarks are about 10x faster than macOS for spider-rs. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Storing Data | ||
|
||
Storing data can be done to collect the raw content for a website. | ||
|
||
This allows you to upload and download the content without UTF-8 conversion. The property only appears when | ||
setting the second param of the `Website` class constructor to true. | ||
|
||
```py | ||
import asyncio | ||
from spider_rs import Website | ||
|
||
class Subscription: | ||
def __init__(self): | ||
print("Subscription Created...") | ||
def __call__(self, page): | ||
print(page.url + " - bytes: " + str(page.raw_content)) | ||
# do something with page.raw_content | ||
|
||
async def main(): | ||
website = Website("https://choosealicense.com") | ||
website.crawl(Subscription(), True) | ||
``` |