mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
Expand binary size benchmark (#830)
This commit is contained in:
parent
591174a686
commit
8c7416b3f6
5 changed files with 71 additions and 14 deletions
|
@ -10,15 +10,10 @@ import sys
|
||||||
import json
|
import json
|
||||||
import time
|
import time
|
||||||
import shutil
|
import shutil
|
||||||
from util import run, run_output, root_path, build_path
|
from util import run, run_output, root_path, build_path, executable_suffix
|
||||||
import tempfile
|
import tempfile
|
||||||
import http_server
|
import http_server
|
||||||
|
|
||||||
try:
|
|
||||||
http_server.spawn()
|
|
||||||
except:
|
|
||||||
"Warning: another http_server instance is running"
|
|
||||||
|
|
||||||
# The list of the tuples of the benchmark name and arguments
|
# The list of the tuples of the benchmark name and arguments
|
||||||
exec_time_benchmarks = [
|
exec_time_benchmarks = [
|
||||||
("hello", ["tests/002_hello.ts"]),
|
("hello", ["tests/002_hello.ts"]),
|
||||||
|
@ -54,6 +49,19 @@ def import_data_from_gh_pages():
|
||||||
write_json(data_file, []) # writes empty json data
|
write_json(data_file, []) # writes empty json data
|
||||||
|
|
||||||
|
|
||||||
|
def get_binary_sizes(build_dir):
|
||||||
|
path_dict = {
|
||||||
|
"deno": os.path.join(build_dir, "deno" + executable_suffix),
|
||||||
|
"main.js": os.path.join(build_dir, "gen/bundle/main.js"),
|
||||||
|
"main.js.map": os.path.join(build_dir, "gen/bundle/main.js.map"),
|
||||||
|
"snapshot_deno.bin": os.path.join(build_dir, "gen/snapshot_deno.bin")
|
||||||
|
}
|
||||||
|
sizes = {}
|
||||||
|
for name, path in path_dict.items():
|
||||||
|
sizes[name] = os.path.getsize(path)
|
||||||
|
return sizes
|
||||||
|
|
||||||
|
|
||||||
def get_strace_summary_text(test_args):
|
def get_strace_summary_text(test_args):
|
||||||
f = tempfile.NamedTemporaryFile()
|
f = tempfile.NamedTemporaryFile()
|
||||||
run(["strace", "-c", "-f", "-o", f.name] + test_args)
|
run(["strace", "-c", "-f", "-o", f.name] + test_args)
|
||||||
|
@ -124,6 +132,8 @@ def main(argv):
|
||||||
print "Usage: tools/benchmark.py [build_dir]"
|
print "Usage: tools/benchmark.py [build_dir]"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
http_server.spawn()
|
||||||
|
|
||||||
deno_path = os.path.join(build_dir, "deno")
|
deno_path = os.path.join(build_dir, "deno")
|
||||||
benchmark_file = os.path.join(build_dir, "benchmark.json")
|
benchmark_file = os.path.join(build_dir, "benchmark.json")
|
||||||
|
|
||||||
|
@ -139,7 +149,7 @@ def main(argv):
|
||||||
new_data = {
|
new_data = {
|
||||||
"created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
"created_at": time.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
||||||
"sha1": sha1,
|
"sha1": sha1,
|
||||||
"binary_size": os.path.getsize(deno_path),
|
"binary_size": {},
|
||||||
"thread_count": {},
|
"thread_count": {},
|
||||||
"syscall_count": {},
|
"syscall_count": {},
|
||||||
"benchmark": {}
|
"benchmark": {}
|
||||||
|
@ -155,6 +165,7 @@ def main(argv):
|
||||||
"max": data["max"]
|
"max": data["max"]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_data["binary_size"] = get_binary_sizes(build_dir)
|
||||||
if "linux" in sys.platform:
|
if "linux" in sys.platform:
|
||||||
# Thread count test, only on linux
|
# Thread count test, only on linux
|
||||||
new_data["thread_count"] = run_thread_count_benchmark(deno_path)
|
new_data["thread_count"] = run_thread_count_benchmark(deno_path)
|
||||||
|
|
|
@ -19,6 +19,14 @@ def strace_parse_test():
|
||||||
assert summary["total"]["calls"] == 704
|
assert summary["total"]["calls"] == 704
|
||||||
|
|
||||||
|
|
||||||
|
def binary_size_test(build_dir):
|
||||||
|
binary_size_dict = benchmark.get_binary_sizes(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
|
||||||
|
|
||||||
|
|
||||||
def thread_count_test(deno_path):
|
def thread_count_test(deno_path):
|
||||||
thread_count_dict = benchmark.run_thread_count_benchmark(deno_path)
|
thread_count_dict = benchmark.run_thread_count_benchmark(deno_path)
|
||||||
assert "set_timeout" in thread_count_dict
|
assert "set_timeout" in thread_count_dict
|
||||||
|
@ -31,8 +39,9 @@ def syscall_count_test(deno_path):
|
||||||
assert syscall_count_dict["hello"] > 1
|
assert syscall_count_dict["hello"] > 1
|
||||||
|
|
||||||
|
|
||||||
def benchmark_test(deno_path):
|
def benchmark_test(build_dir, deno_path):
|
||||||
strace_parse_test()
|
strace_parse_test()
|
||||||
|
binary_size_test(build_dir)
|
||||||
if "linux" in sys.platform:
|
if "linux" in sys.platform:
|
||||||
thread_count_test(deno_path)
|
thread_count_test(deno_path)
|
||||||
syscall_count_test(deno_path)
|
syscall_count_test(deno_path)
|
||||||
|
|
|
@ -41,7 +41,7 @@ def main(argv):
|
||||||
# Internal tools testing
|
# Internal tools testing
|
||||||
setup_test()
|
setup_test()
|
||||||
util_test()
|
util_test()
|
||||||
benchmark_test(deno_exe)
|
benchmark_test(build_dir, deno_exe)
|
||||||
|
|
||||||
test_cc = os.path.join(build_dir, "test_cc" + executable_suffix)
|
test_cc = os.path.join(build_dir, "test_cc" + executable_suffix)
|
||||||
check_exists(test_cc)
|
check_exists(test_cc)
|
||||||
|
|
|
@ -21,8 +21,23 @@ export function createExecTimeColumns(data) {
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const binarySizeNames = ["deno", "main.js", "main.js.map", "snapshot_deno.bin"];
|
||||||
export function createBinarySizeColumns(data) {
|
export function createBinarySizeColumns(data) {
|
||||||
return [["binary_size", ...data.map(d => d.binary_size || 0)]];
|
return binarySizeNames.map(name => [
|
||||||
|
name,
|
||||||
|
...data.map(d => {
|
||||||
|
const binarySizeData = d["binary_size"];
|
||||||
|
switch (typeof binarySizeData) {
|
||||||
|
case "number": // legacy implementation
|
||||||
|
return name === "deno" ? binarySizeData : 0;
|
||||||
|
default:
|
||||||
|
if (!binarySizeData) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return binarySizeData[name] || 0;
|
||||||
|
}
|
||||||
|
})
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
const threadCountNames = ["set_timeout", "fetch_deps"];
|
const threadCountNames = ["set_timeout", "fetch_deps"];
|
||||||
|
|
|
@ -14,7 +14,12 @@ const regularData = [
|
||||||
{
|
{
|
||||||
created_at: "2018-01-01T01:00:00Z",
|
created_at: "2018-01-01T01:00:00Z",
|
||||||
sha1: "abcdef",
|
sha1: "abcdef",
|
||||||
binary_size: 100000000,
|
binary_size: {
|
||||||
|
deno: 100000000,
|
||||||
|
"main.js": 90000000,
|
||||||
|
"main.js.map": 80000000,
|
||||||
|
"snapshot_deno.bin": 70000000
|
||||||
|
},
|
||||||
benchmark: {
|
benchmark: {
|
||||||
hello: {
|
hello: {
|
||||||
mean: 0.05
|
mean: 0.05
|
||||||
|
@ -40,7 +45,12 @@ const regularData = [
|
||||||
{
|
{
|
||||||
created_at: "2018-01-02T01:00:00Z",
|
created_at: "2018-01-02T01:00:00Z",
|
||||||
sha1: "012345",
|
sha1: "012345",
|
||||||
binary_size: 110000000,
|
binary_size: {
|
||||||
|
deno: 100000001,
|
||||||
|
"main.js": 90000001,
|
||||||
|
"main.js.map": 80000001,
|
||||||
|
"snapshot_deno.bin": 70000001
|
||||||
|
},
|
||||||
benchmark: {
|
benchmark: {
|
||||||
hello: {
|
hello: {
|
||||||
mean: 0.055
|
mean: 0.055
|
||||||
|
@ -69,6 +79,7 @@ const irregularData = [
|
||||||
{
|
{
|
||||||
created_at: "2018-01-01T01:00:00Z",
|
created_at: "2018-01-01T01:00:00Z",
|
||||||
sha1: "123",
|
sha1: "123",
|
||||||
|
binary_size: {},
|
||||||
benchmark: {
|
benchmark: {
|
||||||
hello: {},
|
hello: {},
|
||||||
relative_import: {},
|
relative_import: {},
|
||||||
|
@ -81,6 +92,7 @@ const irregularData = [
|
||||||
{
|
{
|
||||||
created_at: "2018-02-01T01:00:00Z",
|
created_at: "2018-02-01T01:00:00Z",
|
||||||
sha1: "456",
|
sha1: "456",
|
||||||
|
binary_size: 100000000,
|
||||||
benchmark: {}
|
benchmark: {}
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
@ -107,12 +119,22 @@ test(function createExecTimeColumnsIrregularData() {
|
||||||
|
|
||||||
test(function createBinarySizeColumnsRegularData() {
|
test(function createBinarySizeColumnsRegularData() {
|
||||||
const columns = createBinarySizeColumns(regularData);
|
const columns = createBinarySizeColumns(regularData);
|
||||||
assertEqual(columns, [["binary_size", 100000000, 110000000]]);
|
assertEqual(columns, [
|
||||||
|
["deno", 100000000, 100000001],
|
||||||
|
["main.js", 90000000, 90000001],
|
||||||
|
["main.js.map", 80000000, 80000001],
|
||||||
|
["snapshot_deno.bin", 70000000, 70000001]
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(function createBinarySizeColumnsIrregularData() {
|
test(function createBinarySizeColumnsIrregularData() {
|
||||||
const columns = createBinarySizeColumns(irregularData);
|
const columns = createBinarySizeColumns(irregularData);
|
||||||
assertEqual(columns, [["binary_size", 0, 0]]);
|
assertEqual(columns, [
|
||||||
|
["deno", 0, 100000000],
|
||||||
|
["main.js", 0, 0],
|
||||||
|
["main.js.map", 0, 0],
|
||||||
|
["snapshot_deno.bin", 0, 0]
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
test(function createThreadCountColumnsRegularData() {
|
test(function createThreadCountColumnsRegularData() {
|
||||||
|
|
Loading…
Reference in a new issue