Add rlib size benchmarks
@@ -169,6 +169,28 @@ fn run_exec_time(deno_exe: &PathBuf, target_dir: &PathBuf) -> Result<Value> {
Ok(Value::Object(results))
}
+fn rlib_size(target_dir: &std::path::Path, prefix: &str) -> u64 {
+ let mut size = 0;
+ let mut seen = std::collections::HashSet::new();
+ for entry in std::fs::read_dir(target_dir.join("deps")).unwrap() {
+ let entry = entry.unwrap();
+ let os_str = entry.file_name();
+ let name = os_str.to_str().unwrap();
+ if name.starts_with(prefix) && name.ends_with(".rlib") {
+ let start = name.split('-').next().unwrap().to_string();
+ if seen.contains(&start) {
+ println!("skip {}", name);
+ } else {
+ seen.insert(start);
+ size += entry.metadata().unwrap().len();
+ println!("check size {} {}", name, size);
+ }
+ }
+ }
+ assert!(size > 0);
+ size
+}
+
const BINARY_TARGET_FILES: &[&str] =
&["CLI_SNAPSHOT.bin", "COMPILER_SNAPSHOT.bin"];
fn get_binary_sizes(target_dir: &PathBuf) -> Result<Value> {
@@ -180,6 +202,18 @@ fn get_binary_sizes(target_dir: &PathBuf) -> Result<Value> {
Value::Number(Number::from(test_util::deno_exe_path().metadata()?.len())),
);
+ // add up size for everything in target/release/deps/libswc*
+ let swc_size = rlib_size(&target_dir, "libswc");
+ println!("swc {} bytes", swc_size);
+ sizes.insert("swc_rlib".to_string(), Value::Number(swc_size.into()));
+
+ let rusty_v8_size = rlib_size(&target_dir, "librusty_v8");
+ println!("rusty_v8 {} bytes", rusty_v8_size);
+ sizes.insert(
+ "rusty_v8_rlib".to_string(),
+ Value::Number(rusty_v8_size.into()),
+ );
+
// Because cargo's OUT_DIR is not predictable, search the build tree for
// snapshot related files.
for file in walkdir::WalkDir::new(target_dir) {
@@ -386,6 +420,9 @@ fn main() -> Result<()> {
let mut new_data: Map<String, Value> = Map::new();
+ new_data.insert("binary_size".to_string(), get_binary_sizes(&target_dir)?);
+ new_data.insert("bundle_size".to_string(), bundle_benchmark(&deno_exe)?);
+
new_data.insert(
"created_at".to_string(),
Value::String(
@@ -416,9 +453,6 @@ fn main() -> Result<()> {
run_exec_time(&deno_exe, &target_dir)?,
);
- new_data.insert("binary_size".to_string(), get_binary_sizes(&target_dir)?);
- new_data.insert("bundle_size".to_string(), bundle_benchmark(&deno_exe)?);
-
// Cannot run throughput benchmark on windows because they don't have nc or
// pipe.
if cfg!(not(target_os = "windows")) {
