mirror of
https://github.com/denoland/deno.git
synced 2024-11-22 15:06:54 -05:00
benchmarks: add bundle size (#2690)
This commit is contained in:
parent
877e5ed784
commit
187310a3e1
3 changed files with 56 additions and 1 deletions
|
@ -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.
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -221,11 +221,34 @@
|
|||
<p>How many threads various programs use.</p>
|
||||
<div id="thread-count-chart"></div>
|
||||
|
||||
<h3 id="syscalls">Syscall count <a href="#syscalls">#</a></h3>
|
||||
<h3 id="bundles">Syscall count <a href="#bundles">#</a></h3>
|
||||
<p>
|
||||
How many total syscalls are performed when executing a given script.
|
||||
</p>
|
||||
<div id="syscall-count-chart"></div>
|
||||
|
||||
<h3 id="bundles">Bundle size <a href="#syscalls">#</a></h3>
|
||||
<p>
|
||||
Size of different bundled scripts.
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<a
|
||||
href="https://deno.land/std/http/file_server.ts"
|
||||
>file_server</a
|
||||
>
|
||||
</li>
|
||||
|
||||
<li>
|
||||
<a
|
||||
href="https://deno.land/std/examples/gist.ts"
|
||||
>gist</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<div id="bundle-size-chart"></div>
|
||||
</main>
|
||||
<script src="https://unpkg.com/d3@5.7.0/dist/d3.min.js"></script>
|
||||
<script src="https://unpkg.com/c3@0.6.7/c3.min.js"></script>
|
||||
|
|
Loading…
Reference in a new issue