Skip to content

Commit 697139b

Browse files
committed
fix benchmark_test
1 parent 6f6e995 commit 697139b

File tree

5 files changed

+28
-24
lines changed

5 files changed

+28
-24
lines changed

cli_snapshots/BUILD.gn

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ action("deno_cli_snapshots_build_run") {
8787
script = "run.py"
8888
inputs = ts_sources
8989
outputs = [
90-
"$root_out_dir/CLI_SNAPSHOT",
90+
"$root_out_dir/CLI_SNAPSHOT.bin",
9191
"$root_out_dir/CLI_SNAPSHOT.js",
9292
"$root_out_dir/CLI_SNAPSHOT.js.map",
9393
"$root_out_dir/CLI_SNAPSHOT.d.ts",
94-
"$root_out_dir/COMPILER_SNAPSHOT",
94+
"$root_out_dir/COMPILER_SNAPSHOT.bin",
9595
"$root_out_dir/COMPILER_SNAPSHOT.js",
9696
"$root_out_dir/COMPILER_SNAPSHOT.js.map",
9797
"$root_out_dir/COMPILER_SNAPSHOT.d.ts",

cli_snapshots/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
pub static CLI_SNAPSHOT: &[u8] =
2-
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT"));
2+
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.bin"));
33
pub static CLI_SNAPSHOT_MAP: &[u8] =
44
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.js.map"));
55
pub static CLI_SNAPSHOT_DTS: &[u8] =
66
include_bytes!(concat!(env!("OUT_DIR"), "/CLI_SNAPSHOT.d.ts"));
77

88
pub static COMPILER_SNAPSHOT: &[u8] =
9-
include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT"));
9+
include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.bin"));
1010
pub static COMPILER_SNAPSHOT_MAP: &[u8] =
1111
include_bytes!(concat!(env!("OUT_DIR"), "/COMPILER_SNAPSHOT.js.map"));
1212
pub static COMPILER_SNAPSHOT_DTS: &[u8] =

deno_typescript/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@ fn snapshot_to_env(
292292
let snapshot_slice =
293293
unsafe { std::slice::from_raw_parts(snapshot.data_ptr, snapshot.data_len) };
294294
println!("snapshot bytes {}", snapshot_slice.len());
295-
//
295+
296296
let out_dir = PathBuf::from(std::env::var_os("OUT_DIR").unwrap());
297-
let snapshot_path = out_dir.join(env_var);
297+
let snapshot_path = out_dir.join(String::from(env_var) + ".bin");
298298

299299
fs::write(&snapshot_path, snapshot_slice)?;
300300
println!("snapshot path {} ", snapshot_path.display());

tools/benchmark.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import json
1212
import time
1313
import shutil
14-
from util import root_path, run, run_output, build_path, executable_suffix
14+
from util import find_exts, root_path, run, run_output, build_path, executable_suffix
1515
import tempfile
1616
import http_server
1717
import throughput_benchmark
@@ -59,22 +59,26 @@ def import_data_from_gh_pages():
5959

6060

6161
def get_binary_sizes(build_dir):
62+
# Because cargo's OUT_DIR is not predictable, we have to search the build
63+
# tree for these files...
64+
files = find_exts([build_dir], ["js", "map", "bin"])
6265
path_dict = {
63-
"deno":
64-
os.path.join(build_dir, "deno" + executable_suffix),
65-
"main.js":
66-
os.path.join(build_dir, "gen/cli/bundle/main.js"),
67-
"main.js.map":
68-
os.path.join(build_dir, "gen/cli/bundle/main.js.map"),
69-
"compiler.js":
70-
os.path.join(build_dir, "gen/cli/bundle/compiler.js"),
71-
"compiler.js.map":
72-
os.path.join(build_dir, "gen/cli/bundle/compiler.js.map"),
73-
"snapshot_deno.bin":
74-
os.path.join(build_dir, "gen/cli/snapshot_deno.bin"),
75-
"snapshot_compiler.bin":
76-
os.path.join(build_dir, "gen/cli/snapshot_compiler.bin")
66+
"deno": os.path.join(build_dir, "deno" + executable_suffix),
7767
}
68+
for f in files:
69+
if f.endswith("CLI_SNAPSHOT.js"):
70+
path_dict["CLI_SNAPSHOT.js"] = f
71+
elif f.endswith("CLI_SNAPSHOT.js.map"):
72+
path_dict["CLI_SNAPSHOT.js.map"] = f
73+
elif f.endswith("CLI_SNAPSHOT.bin"):
74+
path_dict["CLI_SNAPSHOT.bin"] = f
75+
elif f.endswith("COMPILER_SNAPSHOT.js"):
76+
path_dict["COMPILER_SNAPSHOT.js"] = f
77+
elif f.endswith("COMPILER_SNAPSHOT.js.map"):
78+
path_dict["COMPILER_SNAPSHOT.js.map"] = f
79+
elif f.endswith("COMPILER_SNAPSHOT.bin"):
80+
path_dict["COMPILER_SNAPSHOT.bin"] = f
81+
7882
sizes = {}
7983
for name, path in path_dict.items():
8084
assert os.path.exists(path)

tools/benchmark_test.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ def test_max_mem_parse(self):
3232
def test_binary_size(self):
3333
binary_size_dict = benchmark.get_binary_sizes(self.build_dir)
3434
assert binary_size_dict["deno"] > 0
35-
assert binary_size_dict["main.js"] > 0
36-
assert binary_size_dict["main.js.map"] > 0
37-
assert binary_size_dict["snapshot_deno.bin"] > 0
35+
assert binary_size_dict["CLI_SNAPSHOT.js"] > 0
36+
assert binary_size_dict["CLI_SNAPSHOT.js.map"] > 0
37+
assert binary_size_dict["CLI_SNAPSHOT.bin"] > 0
3838

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

0 commit comments

Comments
 (0)