Skip to content

Commit

Permalink
Build test indexes in parallel using rayon.
Browse files Browse the repository at this point in the history
`rayon` is already a transitive dependency for us. Add it as a dev-dependency and use it when deserializing rustdoc and building indexes.

This saves a few more seconds per `cargo test` run.
  • Loading branch information
obi1kenobi committed Dec 1, 2024
1 parent 02ad2c8 commit be10485
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ predicates = "3.1.2"
insta = { version = "1.40.0", features = ["ron", "filters", "toml"] }
regex = "1.10.6"
insta-cmd = "0.6.0"
rayon = "1.10.0"

# In dev and test profiles, compile all dependencies with optimizations enabled,
# but still checking debug assertions and overflows.
Expand Down
5 changes: 3 additions & 2 deletions src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ mod tests {
use std::{collections::BTreeMap, path::Path};

use anyhow::Context;
use rayon::prelude::*;
use serde::{Deserialize, Serialize};
use trustfall::{FieldValue, TransparentValue};
use trustfall_rustdoc::{
Expand Down Expand Up @@ -418,7 +419,7 @@ mod tests {

fn initialize_test_crate_rustdocs() -> BTreeMap<String, (VersionedStorage, VersionedStorage)> {
get_test_crate_names()
.iter()
.par_iter()
.map(|crate_pair| {
let old_rustdoc = load_pregenerated_rustdoc(crate_pair.as_str(), "old");
let new_rustdoc = load_pregenerated_rustdoc(crate_pair, "new");
Expand All @@ -431,7 +432,7 @@ mod tests {
fn initialize_test_crate_indexes(
) -> BTreeMap<String, (VersionedIndex<'static>, VersionedIndex<'static>)> {
get_all_test_crates()
.iter()
.par_iter()
.map(|(key, (old_crate, new_crate))| {
let old_index = VersionedIndex::from_storage(old_crate);
let new_index = VersionedIndex::from_storage(new_crate);
Expand Down

0 comments on commit be10485

Please sign in to comment.