Skip to content

Commit

Permalink
chore(docs): update benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
j-mendez committed Mar 25, 2024
1 parent 43cdaa5 commit e4b3513
Show file tree
Hide file tree
Showing 20 changed files with 58 additions and 81 deletions.
14 changes: 7 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The Rust web accessibility engine.

```toml
[dependencies]
accessibility-rs = "^0.0.58"
accessibility-rs = "^0.0.59"
```

```rs
Expand All @@ -32,11 +32,12 @@ With the Tokio runtime.

```toml
[dependencies]
accessibility-rs = { version = "^0.0.58", features = ["tokio"]}
accessibility-rs = { version = "^0.0.59", features = ["tokio"]}
```

```rs
use accessibility_rs::{audit, AuditConfig};
use tokio;

#[tokio::main]
async fn main() {
Expand Down Expand Up @@ -72,11 +73,11 @@ async fn main() {

```sh
audit-speed/core/audit: small html (4k iterations)
time: [60.988 µs 61.067 µs 61.157 µs]
time: [55.689 µs 56.246 µs 57.110 µs]
audit-speed/core/audit: medium html (4k iterations)
time: [890.56 µs 905.52 µs 923.23 µs]
time: [824.07 µs 830.30 µs 839.37 µs]
audit-speed/core/audit: large html (4k iterations)
time: [1.1316 ms 1.1101 ms 1.1478 ms]
time: [1.1206 ms 1.1260 ms 1.1321 ms]
```

## Examples
Expand Down
6 changes: 3 additions & 3 deletions accessibility-rs/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "accessibility-rs"
version = "0.0.58"
version = "0.0.59"
authors = ["The A11yWatch Project Developers", "Jeff Mendez <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -12,8 +12,8 @@ include = ["/src", "../LICENSE_MIT", "../LICENSE_APACHE", "../README.md", "local

[dependencies]
lazy_static = { workspace = true }
accessibility-scraper = { version = "0.0.9", features = ["main"], default-features = false, path = "../accessibility-scraper" }
accessibility-tree = { version = "0.0.10", path = "../accessibility-tree/victor" }
accessibility-scraper = { version = "0.0.11", features = ["main"], default-features = false, path = "../accessibility-scraper" }
accessibility-tree = { version = "0.0.11", path = "../accessibility-tree/victor" }
getrandom = { version = "0.2", features = ["js"] }
taffy = { version = "0.4.0" }
serde = { version = "1.0", features = ["derive"] }
Expand Down
4 changes: 2 additions & 2 deletions accessibility-rs/src/engine/audit/wcag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl WCAGAAA {
}

/// Audit html against WCAGAAA standards
#[cfg(feature = "rayon")]
#[cfg(all(feature = "rayon", not(feature = "tokio")))]
pub fn audit(auditor: (Auditor<'_>, Option<taffy::TaffyTree>)) -> Vec<Issue> {
use crate::engine::audit::audit_utils::evaluate_rules_in_parallel;

Expand Down Expand Up @@ -121,7 +121,7 @@ impl WCAGAAA {
}

/// Audit html against WCAGAAA standards
#[cfg(all(not(feature = "rayon"), feature = "tokio"))]
#[cfg(feature = "tokio")]
pub async fn audit(auditor: (Auditor<'_>, Option<taffy::TaffyTree>)) -> Vec<Issue> {
WCAGAAA::run_audit(auditor).await
}
Expand Down
9 changes: 9 additions & 0 deletions accessibility-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,20 @@
//! ```no_run
//! use accessibility_rs::{audit, AuditConfig};
//!
//! #[cfg(not(feature = "tokio"))]
//! fn main() {
//! let config = AuditConfig::basic(r###"<html><body><h1>My Title</h1><input type="text" placeholder="Type me"></input><img src="tabby_cat.png"></img></body></html>"###);
//! let audit = audit(config);
//! println!("{:?}", audit);
//! }
//!
//! #[cfg(feature = "tokio")]
//! #[tokio::main]
//! async fn main() {
//! let config = AuditConfig::basic(r###"<html><body><h1>My Title</h1><input type="text" placeholder="Type me"></input><img src="tabby_cat.png"></img></body></html>"###);
//! let audit = audit(config).await;
//! println!("{:?}", audit);
//! }
//! ```
//!
Expand Down
4 changes: 4 additions & 0 deletions accessibility-rs/tests/unit/anchor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use accessibility_rs::AuditConfig;
use maud::html;

#[test]
#[cfg(not(feature = "tokio"))]
/// anchor contains single img element without alt
fn _audit_missing_alt_anchor_img() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand All @@ -26,6 +27,7 @@ fn _audit_missing_alt_anchor_img() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// anchor contains valid href with no content
fn _audit_missing_anchor_content_valid_href() {
let markup = html! {
Expand All @@ -40,6 +42,7 @@ fn _audit_missing_anchor_content_valid_href() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// anchor is empty void
fn _audit_missing_anchor_content() {
let markup = html! {
Expand All @@ -54,6 +57,7 @@ fn _audit_missing_anchor_content() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// anchor text matches img alt
fn _audit_img_alt_matches_text_anchor() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand Down
2 changes: 2 additions & 0 deletions accessibility-rs/tests/unit/applet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use accessibility_rs::AuditConfig;

#[test]
#[cfg(not(feature = "tokio"))]
/// missing applet alt
fn _audit_missing_applet_alt() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand Down Expand Up @@ -30,6 +31,7 @@ fn _audit_missing_applet_alt() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// missing applet body
fn _audit_missing_applet_body() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand Down
2 changes: 2 additions & 0 deletions accessibility-rs/tests/unit/area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use accessibility_rs::AuditConfig;

#[test]
#[cfg(not(feature = "tokio"))]
fn _audit_missing_alt_area() {
//alt attribute missing on first <area> tag
let html = r#"
Expand All @@ -23,6 +24,7 @@ fn _audit_missing_alt_area() {
}

#[test]
#[cfg(not(feature = "tokio"))]
fn _audit_missing_alt_map() {
// alt attribute missing on <map> tag
let html = r#"
Expand Down
1 change: 1 addition & 0 deletions accessibility-rs/tests/unit/contrast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use accessibility_rs::AuditConfig;
use maud::html;

#[test]
#[cfg(not(feature = "tokio"))]
/// anchor has valid contrast.
fn _audit_contrast_text_anchor() {
let markup = html! {
Expand Down
1 change: 1 addition & 0 deletions accessibility-rs/tests/unit/fieldset.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use accessibility_rs::AuditConfig;
use maud::html;

#[test]
#[cfg(not(feature = "tokio"))]
/// anchor contains single img element without alt
fn _audit_missing_fieldset_legend() {
let m = html! {
Expand Down
1 change: 1 addition & 0 deletions accessibility-rs/tests/unit/heading.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use accessibility_rs::AuditConfig;

#[test]
#[cfg(not(feature = "tokio"))]
/// empty headings
fn _audit_headings_empty() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand Down
3 changes: 3 additions & 0 deletions accessibility-rs/tests/unit/img.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use accessibility_rs::AuditConfig;

#[test]
#[cfg(not(feature = "tokio"))]
/// img is missing an alt
fn _audit_img_missing_alt() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand All @@ -27,6 +28,7 @@ fn _audit_img_missing_alt() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// img is missing an alt
fn _audit_form_submit_img_missing_alt() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand Down Expand Up @@ -55,6 +57,7 @@ fn _audit_form_submit_img_missing_alt() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// img has empty alt and title
fn _audit_form_submit_img_has_alt_and_title() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand Down
1 change: 1 addition & 0 deletions accessibility-rs/tests/unit/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
use accessibility_rs::AuditConfig;

#[test]
#[cfg(not(feature = "tokio"))]
/// input is missing a valid name
fn _audit_input_valid_name() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand Down
2 changes: 2 additions & 0 deletions accessibility-rs/tests/unit/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use accessibility_rs::AuditConfig;
use maud::html;

#[test]
#[cfg(not(feature = "tokio"))]
/// label needs unique target ids
fn _audit_label_valid_name() {
let markup = html! {
Expand All @@ -21,6 +22,7 @@ fn _audit_label_valid_name() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// label has id that does not exist
fn _audit_label_id_noexist() {
let markup = html! {
Expand Down
5 changes: 5 additions & 0 deletions accessibility-rs/tests/unit/meta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use accessibility_rs::AuditConfig;
use crate::mocks::mock;

#[test]
#[cfg(not(feature = "tokio"))]
/// missing title element
fn _audit_missing_title() {
let audit = accessibility_rs::audit(AuditConfig::basic(mock::MOCK_WEBSITE_HTML));
Expand All @@ -21,6 +22,7 @@ fn _audit_missing_title() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// meta refresh redirect
fn _audit_meta_refresh() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand Down Expand Up @@ -74,6 +76,7 @@ fn _audit_meta_refresh() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// no blink elements
fn _audit_blink_found() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand All @@ -99,6 +102,7 @@ fn _audit_blink_found() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// iframe missing title
fn _iframe_missing_title() {
let audit = accessibility_rs::audit(AuditConfig {
Expand Down Expand Up @@ -192,6 +196,7 @@ fn _iframe_missing_title() {
}

#[test]
#[cfg(not(feature = "tokio"))]
/// incorrect xml:lang
fn _xml_lang_incorrect_format() {
let audit = accessibility_rs::audit(AuditConfig::basic(
Expand Down
2 changes: 1 addition & 1 deletion accessibility-scraper/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "accessibility-scraper"
version = "0.0.9"
version = "0.0.11"
edition = "2021"
description = "HTML parsing and querying with CSS selectors with CSS binding styles to elements."
keywords = ["html", "css", "selector", "scraping"]
Expand Down
28 changes: 0 additions & 28 deletions accessibility-scraper/examples/document.rs

This file was deleted.

28 changes: 0 additions & 28 deletions accessibility-scraper/examples/fragment.rs

This file was deleted.

Loading

0 comments on commit e4b3513

Please sign in to comment.