Skip to content

Commit

Permalink
fix benchmark_test
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Aug 30, 2019
1 parent 6f6e995 commit 697139b
Showing 5 changed files with 28 additions and 24 deletions.
4 changes: 2 additions & 2 deletions cli_snapshots/BUILD.gn
Original file line number Diff line number Diff line change
@@ -87,11 +87,11 @@ action("deno_cli_snapshots_build_run") {
script = "run.py"
inputs = ts_sources
outputs = [
"$root_out_dir/CLI_SNAPSHOT",
"$root_out_dir/CLI_SNAPSHOT.bin",
"$root_out_dir/CLI_SNAPSHOT.js",
"$root_out_dir/CLI_SNAPSHOT.js.map",
"$root_out_dir/CLI_SNAPSHOT.d.ts",
"$root_out_dir/COMPILER_SNAPSHOT",
"$root_out_dir/COMPILER_SNAPSHOT.bin",
"$root_out_dir/COMPILER_SNAPSHOT.js",
"$root_out_dir/COMPILER_SNAPSHOT.js.map",
"$root_out_dir/COMPILER_SNAPSHOT.d.ts",
4 changes: 2 additions & 2 deletions cli_snapshots/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
pub static CLI_SNAPSHOT: &[u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT"));
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.bin"));
pub static CLI_SNAPSHOT_MAP: &[u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.js.map"));
pub static CLI_SNAPSHOT_DTS: &[u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.d.ts"));

pub static COMPILER_SNAPSHOT: &[u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT"));
include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.bin"));
pub static COMPILER_SNAPSHOT_MAP: &[u8] =
include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.js.map"));
pub static COMPILER_SNAPSHOT_DTS: &[u8] =
4 changes: 2 additions & 2 deletions deno_typescript/lib.rs
Original file line number Diff line number Diff line change
@@ -292,9 +292,9 @@ fn snapshot_to_env(
let snapshot_slice =
unsafe { std::slice::from_raw_parts(snapshot.data_ptr, snapshot.data_len) };
println!("snapshot bytes {}", snapshot_slice.len());
//

let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
let snapshot_path = out_dir.join(env_var);
let snapshot_path = out_dir.join(String::from(env_var) + ".bin");

fs::write(&snapshot_path, snapshot_slice)?;
println!("snapshot path {} ", snapshot_path.display());
34 changes: 19 additions & 15 deletions tools/benchmark.py
Original file line number Diff line number Diff line change
@@ -11,7 +11,7 @@
import json
import time
import shutil
from util import root_path, run, run_output, build_path, executable_suffix
from util import find_exts, root_path, run, run_output, build_path, executable_suffix
import tempfile
import http_server
import throughput_benchmark
@@ -59,22 +59,26 @@ def import_data_from_gh_pages():


def get_binary_sizes(build_dir):
# Because cargo's OUT_DIR is not predictable, we have to search the build
# tree for these files...
files = find_exts([build_dir], ["js", "map", "bin"])
path_dict = {
"deno":
os.path.join(build_dir, "deno" + executable_suffix),
"main.js":
os.path.join(build_dir, "gen/cli/bundle/main.js"),
"main.js.map":
os.path.join(build_dir, "gen/cli/bundle/main.js.map"),
"compiler.js":
os.path.join(build_dir, "gen/cli/bundle/compiler.js"),
"compiler.js.map":
os.path.join(build_dir, "gen/cli/bundle/compiler.js.map"),
"snapshot_deno.bin":
os.path.join(build_dir, "gen/cli/snapshot_deno.bin"),
"snapshot_compiler.bin":
os.path.join(build_dir, "gen/cli/snapshot_compiler.bin")
"deno": os.path.join(build_dir, "deno" + executable_suffix),
}
for f in files:
if f.endswith("CLI_SNAPSHOT.js"):
path_dict["CLI_SNAPSHOT.js"] = f
elif f.endswith("CLI_SNAPSHOT.js.map"):
path_dict["CLI_SNAPSHOT.js.map"] = f
elif f.endswith("CLI_SNAPSHOT.bin"):
path_dict["CLI_SNAPSHOT.bin"] = f
elif f.endswith("COMPILER_SNAPSHOT.js"):
path_dict["COMPILER_SNAPSHOT.js"] = f
elif f.endswith("COMPILER_SNAPSHOT.js.map"):
path_dict["COMPILER_SNAPSHOT.js.map"] = f
elif f.endswith("COMPILER_SNAPSHOT.bin"):
path_dict["COMPILER_SNAPSHOT.bin"] = f

sizes = {}
for name, path in path_dict.items():
assert os.path.exists(path)
6 changes: 3 additions & 3 deletions tools/benchmark_test.py
Original file line number Diff line number Diff line change
@@ -32,9 +32,9 @@ def test_max_mem_parse(self):
def test_binary_size(self):
binary_size_dict = benchmark.get_binary_sizes(self.build_dir)
assert binary_size_dict["deno"] > 0
assert binary_size_dict["main.js"] > 0
assert binary_size_dict["main.js.map"] > 0
assert binary_size_dict["snapshot_deno.bin"] > 0
assert binary_size_dict["CLI_SNAPSHOT.js"] > 0
assert binary_size_dict["CLI_SNAPSHOT.js.map"] > 0
assert binary_size_dict["CLI_SNAPSHOT.bin"] > 0

@unittest.skipIf("linux" not in sys.platform,
"strace only supported on linux")

0 comments on commit 697139b

Please sign in to comment.