-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: use
capacity_builder::FastDisplay
(#42)
- Loading branch information
Showing
8 changed files
with
519 additions
and
126 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,65 @@ | ||
fn main() { | ||
// Run registered benchmarks. | ||
divan::main(); | ||
} | ||
|
||
mod package_req { | ||
use deno_semver::package::PackageReq; | ||
|
||
#[divan::bench(sample_size = 1000)] | ||
fn from_str_loose() -> usize { | ||
PackageReq::from_str_loose("@deno/[email protected]") | ||
.unwrap() | ||
.name | ||
.len() | ||
} | ||
|
||
#[divan::bench(sample_size = 1000)] | ||
fn to_string_normalized() -> usize { | ||
PackageReq::from_str_loose("@deno/[email protected]") | ||
.unwrap() | ||
.to_string_normalized() | ||
.len() | ||
} | ||
} | ||
|
||
mod version { | ||
use deno_semver::Version; | ||
|
||
#[divan::bench(sample_size = 1000)] | ||
fn to_string() -> usize { | ||
version().to_string().len() | ||
} | ||
|
||
#[divan::bench(sample_size = 1000)] | ||
fn to_string_display() -> usize { | ||
format!("{}", version()).len() | ||
} | ||
|
||
fn version() -> Version { | ||
Version::parse_from_npm("1.1.1-pre").unwrap() | ||
} | ||
} | ||
|
||
mod version_req { | ||
use deno_semver::VersionReq; | ||
|
||
#[divan::bench(sample_size = 1000)] | ||
fn to_string() -> usize { | ||
version_req().to_string().len() | ||
} | ||
|
||
#[divan::bench(sample_size = 1000)] | ||
fn to_string_display() -> usize { | ||
format!("{}", version_req()).len() | ||
} | ||
|
||
#[divan::bench(sample_size = 1000)] | ||
fn to_string_normalized() -> usize { | ||
version_req().to_string_normalized().len() | ||
} | ||
|
||
fn version_req() -> VersionReq { | ||
VersionReq::parse_from_npm("^1.1.1-pre").unwrap() | ||
} | ||
} |
Oops, something went wrong.