Skip to content

Commit 3a0c8fa

Browse files
committed
the remaining tables
1 parent 76a666c commit 3a0c8fa

1 file changed

Lines changed: 165 additions & 44 deletions

File tree

baselines/analysis/src/main.rs

Lines changed: 165 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@ use std::borrow::Cow;
1010
use std::error::Error;
1111
use std::fs::File;
1212
use std::io::{BufRead, BufReader};
13-
use std::str::FromStr;
1413

1514
struct OperationData {
1615
crossover: DataRepr,
1716
evaluate: DataRepr,
18-
fix: DataRepr,
17+
// fix: DataRepr,
1918
generate: DataRepr,
2019
mutate: DataRepr,
2120
}
@@ -199,7 +198,7 @@ fn main() -> Result<(), Box<dyn Error>> {
199198
OperationData {
200199
crossover: crossover_data,
201200
evaluate: evaluate_data,
202-
fix: fix_data,
201+
// fix: fix_data,
203202
generate: generate_data,
204203
mutate: mutate_data,
205204
},
@@ -208,12 +207,33 @@ fn main() -> Result<(), Box<dyn Error>> {
208207

209208
let rs_models: HashMap<String, OperationModel> =
210209
serde_json::from_reader(File::open("baselines/profiling-results/rs-models.json")?)?;
211-
// let rs_models_noopt: HashMap<String, OperationModel> = serde_json::from_reader(File::open(
212-
// "baselines/profiling-results/rs-models-noopt.json",
213-
// )?)?;
214-
// let rs_models_noopt_indirect: HashMap<String, OperationModel> = serde_json::from_reader(
215-
// File::open("baselines/profiling-results/rs-models-noopt-indirect.json")?,
216-
// )?;
210+
211+
let maybe_print_rs = |model: &FittedLinearRegression<f64>, suffixes: &[&str]| {
212+
if model.params().iter().all(|&p| p * 1_000_000_000f64 < 0.05) {
213+
Cow::Borrowed(r"\emph{n.d.}\tnote{1}")
214+
} else {
215+
let mut collected = Vec::with_capacity(suffixes.len());
216+
for (idx, suffix) in suffixes.iter().enumerate() {
217+
collected.push(format!(
218+
"{:.2}{suffix}",
219+
model.params()[idx] * 1_000_000_000f64
220+
));
221+
}
222+
Cow::Owned(format!("${}$", collected.join(" + ").replace("+ -", "- ")))
223+
}
224+
};
225+
let maybe_print_py =
226+
|data: &DataRepr, model: &FittedLinearRegression<f64>, suffixes: &[&str]| {
227+
if data.nsamples() < 25 {
228+
Cow::Borrowed(r"\emph{n.d.}\tnote{1}")
229+
} else {
230+
let mut collected = Vec::with_capacity(suffixes.len());
231+
for (idx, suffix) in suffixes.iter().enumerate() {
232+
collected.push(format!("{:.2}{suffix}", model.params()[idx] * 1_000_000f64));
233+
}
234+
Cow::Owned(format!("${}$", collected.join(" + ").replace("+ -", "- ")))
235+
}
236+
};
217237

218238
println!("Table 1: Wall time taken to complete various operations:");
219239
println!(
@@ -228,26 +248,13 @@ fn main() -> Result<(), Box<dyn Error>> {
228248
);
229249
for (&subject, &name) in SUBJECTS.into_iter().zip(PROPER_NAMES) {
230250
let model = rs_models.get(subject).unwrap();
231-
let maybe_print = |model: &FittedLinearRegression<f64>, suffixes: &[&str]| {
232-
if model.params().iter().all(|&p| p * 1_000_000_000f64 < 0.05) {
233-
Cow::Borrowed(r"\emph{n.d.}\tnote{1}")
234-
} else {
235-
let mut collected = Vec::with_capacity(suffixes.len());
236-
for (idx, suffix) in suffixes.iter().enumerate() {
237-
collected.push(format!(
238-
"{:.2}{suffix}",
239-
model.params()[idx] * 1_000_000_000f64
240-
));
241-
}
242-
Cow::Owned(format!("${}$", collected.join(" + ").replace("+ -", "- ")))
243-
}
244-
};
251+
245252
println!(
246253
r" {name} & {} & {} & {} & {} \\",
247-
maybe_print(&model.generate, &["n"]),
248-
maybe_print(model.evaluate.as_ref().unwrap(), &["n"]),
249-
maybe_print(&model.mutate, &["p", "m"]),
250-
maybe_print(&model.crossover, &["p_1", "p_2", "m_1", "m_2"]),
254+
maybe_print_rs(&model.generate, &["n"]),
255+
maybe_print_rs(model.evaluate.as_ref().unwrap(), &["n"]),
256+
maybe_print_rs(&model.mutate, &["p", "m"]),
257+
maybe_print_rs(&model.crossover, &["p_1", "p_2", "m_1", "m_2"]),
251258
)
252259
}
253260
println!(
@@ -263,25 +270,12 @@ fn main() -> Result<(), Box<dyn Error>> {
263270
let model = fandango_models.get(subject).unwrap();
264271
let data = fandango_data.get(subject).unwrap();
265272

266-
let maybe_print = |data: &DataRepr,
267-
model: &FittedLinearRegression<f64>,
268-
suffixes: &[&str]| {
269-
if data.nsamples() < 25 {
270-
Cow::Borrowed(r"\emph{n.d.}\tnote{1}")
271-
} else {
272-
let mut collected = Vec::with_capacity(suffixes.len());
273-
for (idx, suffix) in suffixes.iter().enumerate() {
274-
collected.push(format!("{:.2}{suffix}", model.params()[idx] * 1_000_000f64));
275-
}
276-
Cow::Owned(format!("${}$", collected.join(" + ").replace("+ -", "- ")))
277-
}
278-
};
279273
println!(
280274
r" {name} & {} & {} & {} & {} \\",
281-
maybe_print(&data.generate, &model.generate, &["n"]),
282-
maybe_print(&data.evaluate, model.evaluate.as_ref().unwrap(), &["n"]),
283-
maybe_print(&data.mutate, &model.mutate, &["p", "m"]),
284-
maybe_print(
275+
maybe_print_py(&data.generate, &model.generate, &["n"]),
276+
maybe_print_py(&data.evaluate, model.evaluate.as_ref().unwrap(), &["n"]),
277+
maybe_print_py(&data.mutate, &model.mutate, &["p", "m"]),
278+
maybe_print_py(
285279
&data.crossover,
286280
&model.crossover,
287281
&["p_1", "p_2", "m_1", "m_2"]
@@ -299,5 +293,132 @@ fn main() -> Result<(), Box<dyn Error>> {
299293
.trim_matches('\n')
300294
);
301295

296+
// -------------
297+
298+
println!("Table 2: Wall time of dynamic operations:");
299+
println!(
300+
"{}",
301+
r#"
302+
\begin{tabularx}{\textwidth}{lrrrr}
303+
\toprule
304+
& \textit{Generate} & \textit{Check} & \textit{Mutate} & \textit{Crossover} \\"#
305+
.trim_matches('\n')
306+
);
307+
for (&subject, &name) in SUBJECTS.into_iter().zip(PROPER_NAMES) {
308+
let model = rs_models.get(&format!("{}_dyn", subject)).unwrap();
309+
println!(
310+
r" {name} & {} & \emph{{n.d.}}\tnote{{2}} & {} & {} \\",
311+
maybe_print_rs(&model.generate, &["n"]),
312+
maybe_print_rs(&model.mutate, &["p", "m"]),
313+
maybe_print_rs(&model.crossover, &["p_1", "p_2", "m_1", "m_2"]),
314+
)
315+
}
316+
println!(
317+
"{}",
318+
r#"
319+
\bottomrule
320+
\end{tabularx}
321+
\begin{tablenotes}
322+
\item[1] Optimized out.
323+
\item[2] Unimplemented.
324+
\end{tablenotes}"#
325+
.trim_matches('\n')
326+
);
327+
drop(rs_models);
328+
329+
// -------------
330+
331+
let rs_models_noopt: HashMap<String, OperationModel> = serde_json::from_reader(File::open(
332+
"baselines/profiling-results/rs-models-noopt.json",
333+
)?)?;
334+
335+
println!("Table 3: Wall time taken for unoptimized operations:");
336+
println!(
337+
"{}",
338+
r#"
339+
\begin{tabularx}{\textwidth}{lrrrr}
340+
\toprule
341+
& \multicolumn{4}{c}{\tool{} (static, unoptimized; nanoseconds)} \\
342+
\cmidrule(l{0.25em}r{0.25em}){2-5}
343+
& \textit{Generate} & \textit{Check} & \textit{Mutate} & \textit{Crossover} \\"#
344+
.trim_matches('\n')
345+
);
346+
for (&subject, &name) in SUBJECTS.into_iter().zip(PROPER_NAMES) {
347+
let model = rs_models_noopt.get(subject).unwrap();
348+
println!(
349+
r" {name} & {} & {} & {} & {} \\",
350+
maybe_print_rs(&model.generate, &["n"]),
351+
maybe_print_rs(model.evaluate.as_ref().unwrap(), &["n"]),
352+
maybe_print_rs(&model.mutate, &["p", "m"]),
353+
maybe_print_rs(&model.crossover, &["p_1", "p_2", "m_1", "m_2"]),
354+
)
355+
}
356+
println!(
357+
"{}",
358+
r#"
359+
\midrule
360+
& \multicolumn{4}{c}{\tool{} (dynamic, unoptimized; nanoseconds)} \\
361+
\cmidrule(l{0.25em}r{0.25em}){2-5}
362+
& \textit{Generate} & \textit{Check} & \textit{Mutate} & \textit{Crossover} \\"#
363+
.trim_matches('\n')
364+
);
365+
for (&subject, &name) in SUBJECTS.into_iter().zip(PROPER_NAMES) {
366+
let model = rs_models_noopt.get(&format!("{}_dyn", subject)).unwrap();
367+
println!(
368+
r" {name} & {} & \emph{{n.d.}}\tnote{{2}} & {} & {} \\",
369+
maybe_print_rs(&model.generate, &["n"]),
370+
maybe_print_rs(&model.mutate, &["p", "m"]),
371+
maybe_print_rs(&model.crossover, &["p_1", "p_2", "m_1", "m_2"]),
372+
)
373+
}
374+
println!(
375+
"{}",
376+
r#"
377+
\bottomrule
378+
\end{tabularx}
379+
\begin{tablenotes}
380+
\item[1] Optimized out.
381+
\item[2] Unimplemented.
382+
\end{tablenotes}"#
383+
.trim_matches('\n')
384+
);
385+
drop(rs_models_noopt);
386+
387+
// -------------
388+
389+
let rs_models_noopt_indirect: HashMap<String, OperationModel> = serde_json::from_reader(
390+
File::open("baselines/profiling-results/rs-models-noopt-indirect.json")?,
391+
)?;
392+
393+
println!("Table 4: Wall time of operations without indirection optimization:");
394+
println!(
395+
"{}",
396+
r#"
397+
\begin{tabularx}{\textwidth}{lrrrr}
398+
\toprule
399+
& \textit{Generate} & \textit{Check} & \textit{Mutate} & \textit{Crossover} \\"#
400+
.trim_matches('\n')
401+
);
402+
for (&subject, &name) in SUBJECTS.into_iter().zip(PROPER_NAMES) {
403+
let model = rs_models_noopt_indirect.get(subject).unwrap();
404+
println!(
405+
r" {name} & {} & {} & {} & {} \\",
406+
maybe_print_rs(&model.generate, &["n"]),
407+
maybe_print_rs(model.evaluate.as_ref().unwrap(), &["n"]),
408+
maybe_print_rs(&model.mutate, &["p", "m"]),
409+
maybe_print_rs(&model.crossover, &["p_1", "p_2", "m_1", "m_2"]),
410+
)
411+
}
412+
println!(
413+
"{}",
414+
r#"
415+
\bottomrule
416+
\end{tabularx}
417+
\begin{tablenotes}
418+
\item[1] Optimized out.
419+
\end{tablenotes}"#
420+
.trim_matches('\n')
421+
);
422+
302423
Ok(())
303424
}

0 commit comments

Comments
 (0)