From 187310a3e151303504a1dc5830334ae7ac1fef57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Sun, 28 Jul 2019 12:11:08 +0200 Subject: [PATCH] benchmarks: add bundle size (#2690) --- tools/benchmark.py | 22 ++++++++++++++++++++++ website/app.ts | 10 ++++++++++ website/benchmarks.html | 25 ++++++++++++++++++++++++- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/tools/benchmark.py b/tools/benchmark.py index 41dbc5b96f..8615a17d98 100755 --- a/tools/benchmark.py +++ b/tools/benchmark.py @@ -203,6 +203,27 @@ def run_http(build_dir, new_data): new_data["max_latency"] = {k: v["max_latency"] for k, v in stats.items()} +def bundle_benchmark(deno_exe): + bundles = { + "file_server": "https://deno.land/std/http/file_server.ts", + "gist": "https://deno.land/std/examples/gist.ts", + } + + sizes = {} + + for name, url in bundles.items(): + # bundle + run([deno_exe, "bundle", url]) + path = name + ".bundle.js" + # get size of bundle + assert os.path.exists(path) + sizes[name] = os.path.getsize(path) + # remove bundle + os.remove(path) + + return sizes + + def main(argv): if len(argv) == 2: build_dir = sys.argv[1] @@ -232,6 +253,7 @@ def main(argv): new_data["benchmark"] = run_exec_time(deno_exe, build_dir) new_data["binary_size"] = get_binary_sizes(build_dir) + new_data["bundle_size"] = bundle_benchmark(deno_exe) # Cannot run throughput benchmark on windows because they don't have nc or # pipe. diff --git a/website/app.ts b/website/app.ts index c93ed09868..326e02f635 100644 --- a/website/app.ts +++ b/website/app.ts @@ -108,10 +108,18 @@ export function createSyscallCountColumns(data) { ]); } +export function createBundleSizeColumns(data) { + return createColumns(data, "bundle_size"); +} + export function createSha1List(data) { return data.map(d => d.sha1); } +export function formatKB(bytes) { + return (bytes / 1024).toFixed(2); +} + export function formatMB(bytes) { return (bytes / (1024 * 1024)).toFixed(2); } @@ -247,6 +255,7 @@ export async function drawChartsFromBenchmarkData(dataUrl) { const binarySizeColumns = createBinarySizeColumns(data); const threadCountColumns = createThreadCountColumns(data); const syscallCountColumns = createSyscallCountColumns(data); + const bundleSizeColumns = createBundleSizeColumns(data); const sha1List = createSha1List(data); const sha1ShortList = sha1List.map(sha1 => sha1.substring(0, 6)); @@ -277,6 +286,7 @@ export async function drawChartsFromBenchmarkData(dataUrl) { gen("#binary-size-chart", binarySizeColumns, "megabytes", formatMB); gen("#thread-count-chart", threadCountColumns, "threads"); gen("#syscall-count-chart", syscallCountColumns, "syscalls"); + gen("#bundle-size-chart", bundleSizeColumns, "kilobytes", formatKB); } export function main(): void { diff --git a/website/benchmarks.html b/website/benchmarks.html index 8b2b44d729..68e1fa57d3 100644 --- a/website/benchmarks.html +++ b/website/benchmarks.html @@ -221,11 +221,34 @@

How many threads various programs use.

-

Syscall count #

+

Syscall count #

How many total syscalls are performed when executing a given script.

+ +

Bundle size #

+

+ Size of different bundled scripts. +

+ + + +