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 Oct 23, 2023
1 parent 8482953 commit 44e9e51
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 63 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ let audit = accessibility_rs::audit(&AuditConfig::new(&html, &css, false, "en"))

```sh
audit-speed/core/audit: small html (4k iterations)
time: [66.025 µs 66.151 µs 66.270 µs]
time: [60.988 µs 61.067 µs 61.157 µs]
audit-speed/core/audit: medium html (4k iterations)
time: [928.16 µs 931.17 µs 933.96 µs]
time: [890.56 µs 905.52 µs 923.23 µs]
audit-speed/core/audit: large html (4k iterations)
time: [1.1475 ms 1.1507 ms 1.1531 ms]
time: [1.1316 ms 1.1101 ms 1.1478 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.43"
version = "0.0.44"
authors = ["The A11yWatch Project Developers", "Jeff Mendez <[email protected]>"]
edition = "2021"
license = "MIT OR Apache-2.0"
Expand All @@ -15,8 +15,8 @@ default = []

[dependencies]
lazy_static = { workspace = true }
accessibility-scraper = { version = "0.0.4", features = ["main"], default-features = false, path = "../accessibility-scraper" }
accessibility-tree = { version = "0.0.4", path = "../accessibility-tree/victor" }
accessibility-scraper = { version = "0.0.5", features = ["main"], default-features = false, path = "../accessibility-scraper" }
accessibility-tree = { version = "0.0.5", path = "../accessibility-tree/victor" }
getrandom = { version = "0.2", features = ["js"] }
taffy = { version = "0.3.13" }
serde = { version = "1.0", features = ["derive"] }
Expand Down
10 changes: 4 additions & 6 deletions accessibility-rs/src/engine/audit/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,14 @@ pub fn parse_accessibility_tree_bounded<'a, 'b, 'c>(
)
.unwrap();

println!("Layout leafs {:?}", layout_leafs.len());
// println!("Layout leafs {:?}", layout_leafs.len());

// TODO: set the root node to html, body in the accessibility_tree
taffy.compute_layout(root_node, Size::MAX_CONTENT).unwrap();

for lea in layout_leafs {
println!("Leaf Position {:?}", taffy.layout(lea).unwrap());
}
// console_log!("Getting tree links {:?}", accessibility_tree.get("a"));
// console_log!("Tree {:?}", accessibility_tree);
// for lea in layout_leafs {
// println!("Leaf Position {:?}", taffy.layout(lea).unwrap());
// }

(accessibility_tree, Some(taffy), matching_context)
}
2 changes: 1 addition & 1 deletion accessibility-rs/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ fn _audit() {
let report = accessibility_rs::audit(AuditConfig::new(
mock::MOCK_WEBSITE_HTML,
&mock::MOCK_CSS_RULES,
false,
true,
"en",
));
println!("{:?}", report)
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.4"
version = "0.0.5"
edition = "2021"

description = "HTML parsing and querying with CSS selectors with CSS binding styles to elements."
Expand Down
4 changes: 3 additions & 1 deletion accessibility-scraper/src/selector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ impl Selector {
}

/// An implementation of `Parser` for `selectors`
struct Parser;
#[derive(Debug, Clone, Copy)]
pub struct Parser;

impl<'i> parser::Parser<'i> for Parser {
type Impl = Simple;
type Error = SelectorParseErrorKind<'i>;
Expand Down
4 changes: 2 additions & 2 deletions accessibility-tree/victor/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "accessibility-tree"
version = "0.0.4"
version = "0.0.5"
authors = ["Jeff Mendez <[email protected]"]
license = "MIT OR Apache-2.0"
description = "Accessibility tree binding CSS styles and vectors to elements. Used mainly for accessibility-rs crate."
Expand All @@ -22,7 +22,7 @@ lock_api = "0.1"
num-traits = "0.2"
rayon = "1"
rayon_croissant = "0.1.1"
accessibility-scraper = { version = "0.0.4", features = ["main"], default-features = false, path = "../../accessibility-scraper" }
accessibility-scraper = { version = "0.0.5", features = ["main"], default-features = false, path = "../../accessibility-scraper" }
selectors = { workspace = true }
smallbitvec = "2.4"
smallvec = { workspace = true }
Expand Down
44 changes: 1 addition & 43 deletions accessibility-tree/victor/src/style/selectors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ use crate::dom::{Document, Node, NodeId};
use crate::style::errors::RuleParseErrorKind;
use accessibility_scraper::selector::CssLocalName;
use accessibility_scraper::selector::Simple;
use cssparser::ToCss;
use html5ever::{LocalName, Namespace};
use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint};
use selectors::context::{MatchingContext, MatchingMode, QuirksMode};
use selectors::matching::{matches_selector, ElementSelectorFlags};
use std::fmt;

pub type SelectorList = selectors::SelectorList<Simple>;
pub type Selector = selectors::parser::Selector<Simple>;
Expand All @@ -26,54 +24,14 @@ pub fn matches(selector: &Selector, document: &Document, element: NodeId) -> boo
)
}

/// css parser
pub struct Parser;

#[derive(Clone, PartialEq, Eq)]
pub enum PseudoElement {}

#[derive(Clone, PartialEq, Eq)]
pub enum PseudoClass {}

impl selectors::parser::NonTSPseudoClass for PseudoClass {
type Impl = Simple;
fn is_active_or_hover(&self) -> bool {
match *self {}
}
fn is_user_action_state(&self) -> bool {
false
}
fn has_zero_specificity(&self) -> bool {
false
}
}

impl<'i> selectors::parser::Parser<'i> for Parser {
type Impl = Simple;
type Error = RuleParseErrorKind<'i>;
}

impl selectors::parser::PseudoElement for PseudoElement {
type Impl = Simple;
}

impl ToCss for PseudoElement {
fn to_css<W>(&self, _dest: &mut W) -> fmt::Result
where
W: fmt::Write,
{
match *self {}
}
}

impl ToCss for PseudoClass {
fn to_css<W>(&self, _dest: &mut W) -> fmt::Result
where
W: fmt::Write,
{
match *self {}
}
}

#[derive(Copy, Clone)]
struct NodeRef<'a> {
document: &'a Document,
Expand Down

0 comments on commit 44e9e51

Please sign in to comment.