Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lscpu in output #78

Merged
merged 6 commits into from
Apr 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
run: |

lscpu
rustc --version --verbose

git config --global user.name github-actions
git config --global user.email github-actions@github.com
Expand Down
6 changes: 6 additions & 0 deletions tools/README.md.template
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ Some benchmark results may be italicized and followed by an asterisk. Mouse over

## Last updated: {date}

<details><summary>Runtime info</summary>

{runtime_info}

</details>

{tables}{links}

## Footnotes:
Expand Down
28 changes: 24 additions & 4 deletions tools/bencher/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@ fn main() {
.stdout;
fs::write(&metadata_path, metadata).unwrap();

let rustc_info_path = NamedTempFile::new().unwrap().into_temp_path();
let rustc_version = Command::new("rustc")
.args(["--version", "--verbose"])
.output()
.unwrap()
.stdout;
fs::write(&rustc_info_path, rustc_version).unwrap();

#[cfg(target_os = "linux")]
let cpu_info_path = {
let cpu_info_path = NamedTempFile::new().unwrap().into_temp_path();
let lscpu = Command::new("lscpu").output().unwrap().stdout;
fs::write(&cpu_info_path, lscpu).unwrap();
cpu_info_path
};

let mut bench_path = PathBuf::from("benchmark_results");
bench_path.push(&format!(
"{}-{}-{}_{}-{}-{}",
Expand All @@ -39,17 +55,21 @@ fn main() {

let mut json_path = bench_path.clone();
json_path.set_extension("json");
Command::new("cargo")
let mut parser = Command::new("cargo");
parser
.args(["run", "-p", "parser", "--"])
.arg(&log_path)
.arg("--config")
.arg(&config_path)
.arg("--meta")
.arg(&metadata_path)
.arg("--rustc-info")
.arg(&rustc_info_path)
.arg("--output")
.arg(&json_path)
.status()
.unwrap();
.arg(&json_path);
#[cfg(target_os = "linux")]
parser.arg("--cpu-info").arg(&cpu_info_path);
parser.status().unwrap();

let mut template_path = PathBuf::from("tools");
template_path.push("README.md.template");
Expand Down
24 changes: 24 additions & 0 deletions tools/formatter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,29 @@ fn format(
];
const ZCD_COLS: &[&str] = &["access", "read", "update"];

let mut runtime_info = format!(
"\
### `rustc` version\n\
\n\
```\n\
{}\n\
```",
results.rustc_info.trim_end(),
);
for cpu_info in &results.cpu_info {
write!(
&mut runtime_info,
"\n\
\n\
### CPU info\n\
\n\
```\n\
{}\n\
```",
cpu_info.trim_end(),
)?;
}

let mut tables = String::new();

for (dataset_name, dataset) in results.datasets.iter() {
Expand Down Expand Up @@ -276,6 +299,7 @@ fn format(
Ok(template
.replace("{dne}", &config.do_not_edit)
.replace("{date}", date)
.replace("{runtime_info}", &runtime_info)
.replace("{tables}", &tables)
.replace("{links}", &links))
}
15 changes: 14 additions & 1 deletion tools/parser/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ struct Args {
config: PathBuf,
#[arg(long)]
meta: PathBuf,
#[arg(long)]
rustc_info: PathBuf,
#[arg(long)]
cpu_info: Option<PathBuf>,
#[arg(short, long)]
output: PathBuf,
}
Expand All @@ -36,14 +40,23 @@ fn main() {
let config = Config::read(&args.config);
let metadata =
serde_json::from_str::<Metadata>(&fs::read_to_string(args.meta).unwrap()).unwrap();
let rustc_info = fs::read_to_string(&args.rustc_info).unwrap();
let cpu_info = args
.cpu_info
.as_ref()
.map(|path| fs::read_to_string(path).unwrap());

let time_benches_re = Regex::new(
r"(?m)^([a-z0-9_\-]+)\/([a-z0-9_\-]+)\/([a-z0-9_\-]+)(?: \(([a-z0-9_\-+ ]*)\))?\s+time: \[\d+\.\d+ [µnm]s (\d+\.\d+ [µnm]s)"
).unwrap();
let size_benches_re =
Regex::new(r"(?m)^([a-z0-9_\-]+)\/([a-z0-9_\-]+)\/(size|zlib|zstd) (\d+)").unwrap();

let mut results = Results::default();
let mut results = Results {
cpu_info,
rustc_info,
..Default::default()
};

for capture in time_benches_re.captures_iter(&log) {
let feature = &capture[2];
Expand Down
2 changes: 2 additions & 0 deletions tools/schema/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ impl Config {

#[derive(Default, Deserialize, Serialize)]
pub struct Results {
pub cpu_info: Option<String>,
pub rustc_info: String,
pub datasets: BTreeMap<String, Dataset>,
pub features: Features,
}
Expand Down
Loading