-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: added http execute benchmark (#1910)
Co-authored-by: Tushar Mathur <[email protected]>
- Loading branch information
1 parent
7f9913d
commit 71e789e
Showing
12 changed files
with
398 additions
and
18 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 @@ | ||
use criterion::Criterion; | ||
use hyper::Method; | ||
use tailcall::cli::runtime::NativeHttp; | ||
use tailcall::core::blueprint::Blueprint; | ||
use tailcall::core::HttpIO; | ||
|
||
pub fn benchmark_http_execute_method(c: &mut Criterion) { | ||
let tokio_runtime = tokio::runtime::Runtime::new().unwrap(); | ||
|
||
let mut blueprint = Blueprint::default(); | ||
blueprint.upstream.http_cache = true; // allow http caching for bench test. | ||
let native_http = NativeHttp::init(&blueprint.upstream, &blueprint.telemetry); | ||
let request_url = String::from("http://jsonplaceholder.typicode.com/users"); | ||
|
||
tokio_runtime.block_on(async { | ||
// cache the 1st request in order the evaluate the perf of underlying cache. | ||
let request = reqwest::Request::new(Method::GET, request_url.parse().unwrap()); | ||
let _result = native_http.execute(request).await; | ||
}); | ||
|
||
c.bench_function("test_http_execute_method", |b| { | ||
b.iter(|| { | ||
tokio_runtime.block_on(async { | ||
let request = reqwest::Request::new(Method::GET, request_url.parse().unwrap()); | ||
let _result = native_http.execute(request).await; | ||
}) | ||
}); | ||
}); | ||
} |
Oops, something went wrong.
71e789e
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Running 30s test @ http://localhost:8000/graphql
4 threads and 100 connections
450162 requests in 30.00s, 2.26GB read
Requests/sec: 15003.88
Transfer/sec: 77.01MB