mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 06:03:58 +00:00
fix: FIx mbe bench tests being iteration order dependent
This commit is contained in:
parent
70d0b57cf0
commit
02e189dcb5
1 changed files with 8 additions and 5 deletions
|
@ -3,6 +3,7 @@
|
||||||
use intern::Symbol;
|
use intern::Symbol;
|
||||||
use rustc_hash::FxHashMap;
|
use rustc_hash::FxHashMap;
|
||||||
use span::{Edition, Span};
|
use span::{Edition, Span};
|
||||||
|
use stdx::itertools::Itertools;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, HasName},
|
ast::{self, HasName},
|
||||||
AstNode,
|
AstNode,
|
||||||
|
@ -27,9 +28,10 @@ fn benchmark_parse_macro_rules() {
|
||||||
let hash: usize = {
|
let hash: usize = {
|
||||||
let _pt = bench("mbe parse macro rules");
|
let _pt = bench("mbe parse macro rules");
|
||||||
rules
|
rules
|
||||||
.values()
|
.into_iter()
|
||||||
.map(|it| {
|
.sorted_by_key(|(id, _)| id.clone())
|
||||||
DeclarativeMacro::parse_macro_rules(it, |_| span::Edition::CURRENT).rules.len()
|
.map(|(_, it)| {
|
||||||
|
DeclarativeMacro::parse_macro_rules(&it, |_| span::Edition::CURRENT).rules.len()
|
||||||
})
|
})
|
||||||
.sum()
|
.sum()
|
||||||
};
|
};
|
||||||
|
@ -55,12 +57,13 @@ fn benchmark_expand_macro_rules() {
|
||||||
})
|
})
|
||||||
.sum()
|
.sum()
|
||||||
};
|
};
|
||||||
assert_eq!(hash, 76353);
|
assert_eq!(hash, 65720);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn macro_rules_fixtures() -> FxHashMap<String, DeclarativeMacro> {
|
fn macro_rules_fixtures() -> FxHashMap<String, DeclarativeMacro> {
|
||||||
macro_rules_fixtures_tt()
|
macro_rules_fixtures_tt()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
.sorted_by_key(|(id, _)| id.clone())
|
||||||
.map(|(id, tt)| (id, DeclarativeMacro::parse_macro_rules(&tt, |_| span::Edition::CURRENT)))
|
.map(|(id, tt)| (id, DeclarativeMacro::parse_macro_rules(&tt, |_| span::Edition::CURRENT)))
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
|
@ -93,7 +96,7 @@ fn invocation_fixtures(
|
||||||
let mut seed = 123456789;
|
let mut seed = 123456789;
|
||||||
let mut res = Vec::new();
|
let mut res = Vec::new();
|
||||||
|
|
||||||
for (name, it) in rules {
|
for (name, it) in rules.iter().sorted_by_key(|&(id, _)| id) {
|
||||||
for rule in it.rules.iter() {
|
for rule in it.rules.iter() {
|
||||||
// Generate twice
|
// Generate twice
|
||||||
for _ in 0..2 {
|
for _ in 0..2 {
|
||||||
|
|
Loading…
Reference in a new issue