mirror of
https://github.com/storytold/wordcraft.git
synced 2026-10-28 04:17:06 -06:00
#3692: review — formats timing tests get a margin a busy CI machine can't break
many_formatted_leading_breaks_trim_quickly failed at its 2 s bound on a machine at load ~50 (it takes about a second there). Bounds now sit at least 10x over the fixed code's time on a loaded machine and far under the old code's on the same input (measured by running the pre-fix code, capped at 400 s): - HTML leading breaks: 2 s -> 20 s; ~1 s now, old trim ran past 6 minutes. - LaTeX nested multicolumn: 2 s -> 10 s; under 1 s now, old unwrapping took 213 s. - Markdown delimiters: 2 s -> 10 s; under 1 s now, old backwards search past 6 minutes. - Para::trim blank spans: 1 s -> 10 s; 0.16 s now, old Vec::remove(0) past 6 minutes. - repeated sheet headers: 2 s -> 10 s; 20 ms now, old numbering past 6 minutes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CX1hMKX28764Lrx5moxs1o
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
124243b1be
commit
22df7caf4d
@@ -2435,7 +2435,8 @@ mod tests {
|
||||
let html = format!("<p>{}x</p>", "<b><br></b><i><br></i>".repeat(100_000));
|
||||
let t = std::time::Instant::now();
|
||||
let f = parse(&html);
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(2), "{:?}", t.elapsed());
|
||||
// About a second on a loaded machine; trimming one span at a time ran past 6 minutes.
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(20), "{:?}", t.elapsed());
|
||||
let texts: Vec<String> = f.blocks.iter().filter_map(|b| if let FBlock::Para(p) = b { Some(p.text()) } else { None }).collect();
|
||||
assert_eq!(texts, ["x"]);
|
||||
}
|
||||
|
||||
@@ -3264,7 +3264,8 @@ Caf\'e na\"ive \c{c}a \v{s}\'{e} and {\bfseries grouped bold} after.
|
||||
let src = format!("\\begin{{tabular}}{{l}}{}x{}\\\\\\end{{tabular}}", "\\multicolumn{1}{c}{".repeat(n), "}".repeat(n));
|
||||
let t = std::time::Instant::now();
|
||||
let f = parse(&src);
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(2), "{:?}", t.elapsed());
|
||||
// Under a second on a loaded machine; unwrapping every wrapper took 213 s.
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(10), "{:?}", t.elapsed());
|
||||
assert!(f.blocks.iter().any(|b| matches!(b, FBlock::Table(_))));
|
||||
// One or two wrappers, as written in real tables, are still read.
|
||||
let f = parse("\\begin{tabular}{ll}\\multicolumn{2}{c}{\\multirow{2}{*}{Both}}\\\\\\end{tabular}");
|
||||
|
||||
@@ -2203,7 +2203,8 @@ mod tests {
|
||||
let src = "*_".repeat(200_000);
|
||||
let t = std::time::Instant::now();
|
||||
let out = inl(&src);
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(2), "{:?}", t.elapsed());
|
||||
// Under a second on a loaded machine; the backwards search ran past 6 minutes.
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(10), "{:?}", t.elapsed());
|
||||
let text: String = out.iter().filter_map(|i| if let Inline::Text(t, _) = i { Some(t.as_str()) } else { None }).collect();
|
||||
assert!(text.chars().all(|c| matches!(c, '*' | '_')), "only delimiters come out");
|
||||
// Literal delimiters still take the link of the text before them.
|
||||
|
||||
@@ -1669,7 +1669,8 @@ mod tests {
|
||||
p.push_text(" x ", &Fmt::default());
|
||||
let t = std::time::Instant::now();
|
||||
p.trim();
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(1), "{:?}", t.elapsed());
|
||||
// A fraction of a second; `Vec::remove(0)` per span ran past 6 minutes.
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(10), "{:?}", t.elapsed());
|
||||
assert_eq!(p.inlines, vec![Inline::Text("x".into(), Fmt::default())]);
|
||||
// The first span left keeps its formatting and loses only its leading blanks.
|
||||
let mut p = Para::default();
|
||||
|
||||
@@ -1252,7 +1252,8 @@ mod tests {
|
||||
let row = vec!["Name".to_string(); 5_000];
|
||||
let t = std::time::Instant::now();
|
||||
let names = field_names(&row);
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(2), "{:?}", t.elapsed());
|
||||
// Milliseconds; the old numbering ran past 6 minutes.
|
||||
assert!(t.elapsed() < std::time::Duration::from_secs(10), "{:?}", t.elapsed());
|
||||
assert_eq!(names.len(), 5_000);
|
||||
assert_eq!(names[0], "Name");
|
||||
assert_eq!(names[4_999], "Name 5000");
|
||||
|
||||
Reference in New Issue
Block a user