Add scripts for running perf and callgrind.

This commit is contained in:
Tom Alexander
2023-08-21 01:26:52 -04:00
parent 8561fdc1bd
commit 655af88cdf
4 changed files with 43 additions and 10 deletions

View File

@@ -1,8 +1,6 @@
#![feature(round_char_boundary)]
#[cfg(feature = "compare")]
use std::io::Read;
#[cfg(feature = "compare")]
use ::organic::parser::document;
#[cfg(feature = "compare")]
use organic::compare_document;
@@ -37,14 +35,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
#[cfg_attr(feature = "tracing", tracing::instrument(ret, level = "debug"))]
fn main_body() -> Result<(), Box<dyn std::error::Error>> {
#[cfg(not(feature = "compare"))]
let org_contents = "";
#[cfg(feature = "compare")]
let org_contents = read_stdin_to_string()?;
run_compare(org_contents)
}
#[cfg(feature = "compare")]
fn read_stdin_to_string() -> Result<String, Box<dyn std::error::Error>> {
let mut stdin_contents = String::new();
std::io::stdin()
@@ -79,7 +73,9 @@ fn run_compare<P: AsRef<str>>(org_contents: P) -> Result<(), Box<dyn std::error:
}
#[cfg(not(feature = "compare"))]
fn run_compare<P: AsRef<str>>(_org_contents: P) -> Result<(), Box<dyn std::error::Error>> {
println!("This program was built with compare disabled. Doing nothing.");
fn run_compare<P: AsRef<str>>(org_contents: P) -> Result<(), Box<dyn std::error::Error>> {
eprintln!("This program was built with compare disabled. Dumping the AST from rust.");
let (remaining, rust_parsed) = document(org_contents.as_ref()).expect("Org Parse failure");
println!("{:#?}", rust_parsed);
Ok(())
}