-
Notifications
You must be signed in to change notification settings - Fork 111
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf(client): fix blocking and async mixture (#39)
- Loading branch information
Showing
12 changed files
with
88 additions
and
49 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,39 @@ | ||
name: Benches | ||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
env: | ||
CARGO_TERM_COLOR: always | ||
RUST_LOG: "off" | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/cache@v2 | ||
id: cache | ||
with: | ||
path: | | ||
~/.cargo/bin/ | ||
~/.cargo/registry/index/ | ||
~/.cargo/registry/cache/ | ||
~/.cargo/git/db/ | ||
target/ | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} | ||
- name: Install Benchmark Dependencies | ||
run: | | ||
# install node-crawler | ||
npm install -g crawler | ||
# install go and deps | ||
go mod init example.com/spider | ||
go get github.com/gocolly/colly/v2 | ||
cat go.mod | ||
go mod tidy | ||
# install the local cli latest | ||
cd ./spider_cli && cargo install --path . && cd ../ | ||
- name: Run Benchmarks | ||
run: cargo bench |
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 |
---|---|---|
|
@@ -4,4 +4,5 @@ node_modules | |
node-crawler.js | ||
go-crolly.go | ||
go.mod | ||
go.sum | ||
go.sum | ||
output.txt |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "spider_examples" | ||
version = "1.5.5" | ||
version = "1.6.0" | ||
authors = ["madeindjs <[email protected]>", "j-mendez <[email protected]>"] | ||
description = "Multithreaded web crawler written in Rust." | ||
repository = "https://github.com/madeindjs/spider" | ||
|
@@ -15,7 +15,7 @@ publish = false | |
maintenance = { status = "as-is" } | ||
|
||
[dependencies.spider] | ||
version = "1.5.5" | ||
version = "1.6.0" | ||
path = "../spider" | ||
default-features = false | ||
|
||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "spider" | ||
version = "1.5.5" | ||
version = "1.6.0" | ||
authors = ["madeindjs <[email protected]>", "j-mendez <[email protected]>"] | ||
description = "Multithreaded web crawler written in Rust." | ||
repository = "https://github.com/madeindjs/spider" | ||
|
@@ -15,7 +15,7 @@ edition = "2018" | |
maintenance = { status = "as-is" } | ||
|
||
[dependencies] | ||
reqwest = { version = "0.11.10" } | ||
reqwest = { version = "0.11.10", features = ["blocking"] } | ||
scraper = "0.12" | ||
robotparser-fork = "0.10.5" | ||
url = "2.2" | ||
|
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 |
---|---|---|
@@ -1,8 +1,18 @@ | ||
pub use crate::reqwest::{Client, Error}; | ||
pub use crate::reqwest::blocking::{Client}; | ||
use reqwest::StatusCode; | ||
|
||
#[tokio::main] | ||
pub async fn fetch_page_html(url: &str, client: &Client) -> Result<String, Error> { | ||
let body = client.get(url).send().await?.text().await?; | ||
pub fn fetch_page_html(url: &str, client: &Client) -> String { | ||
let mut body = String::new(); | ||
|
||
Ok(body) | ||
// silence errors for top level logging | ||
match client.get(url).send() { | ||
Ok(res) if res.status() == StatusCode::OK => match res.text() { | ||
Ok(text) => body = text, | ||
Err(_) => {}, | ||
}, | ||
Ok(_) => (), | ||
Err(_) => {} | ||
} | ||
|
||
body | ||
} |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "spider_cli" | ||
version = "1.5.5" | ||
version = "1.6.0" | ||
authors = ["madeindjs <[email protected]>", "j-mendez <[email protected]>"] | ||
description = "Multithreaded web crawler written in Rust." | ||
repository = "https://github.com/madeindjs/spider" | ||
|
@@ -23,7 +23,7 @@ quote = "1.0.18" | |
failure_derive = "0.1.8" | ||
|
||
[dependencies.spider] | ||
version = "1.5.5" | ||
version = "1.6.0" | ||
path = "../spider" | ||
default-features = false | ||
|
||
|