ec63b36994
This PR optimizes `Event` constructor - ~Added a fast path for empty `eventInitDict`~ Removed `EventInit` dictionary converter - Don't make `isTrusted` a [LegacyUnforgeable](https://webidl.spec.whatwg.org/#LegacyUnforgeable) property. Doing so makes it non-spec compliant but calling `Object/Reflect.defineProperty` on the constructor is a big bottleneck. Node did the same a few months ago https://github.com/nodejs/node/pull/46974. In my opinion, the performance gains are worth deviating from the spec for a browser-related property. **This PR** ``` cpu: 13th Gen Intel(R) Core(TM) i9-13900H runtime: deno 1.36.1 (x86_64-unknown-linux-gnu) benchmark time (avg) iter/s (min … max) p75 p99 p995 ------------------------------------------------------------------------------- ----------------------------- event constructor no init 36.69 ns/iter 27,257,504.6 (33.36 ns … 42.45 ns) 37.71 ns 39.61 ns 40.07 ns event constructor 36.7 ns/iter 27,246,776.6 (33.35 ns … 56.03 ns) 37.73 ns 40.14 ns 41.74 ns ``` **main** ``` cpu: 13th Gen Intel(R) Core(TM) i9-13900H runtime: deno 1.36.1 (x86_64-unknown-linux-gnu) benchmark time (avg) iter/s (min … max) p75 p99 p995 ------------------------------------------------------------------------------- ----------------------------- event constructor no init 380.48 ns/iter 2,628,275.8 (366.66 ns … 399.39 ns) 384.58 ns 398.27 ns 399.39 ns event constructor 480.33 ns/iter 2,081,882.6 (466.67 ns … 503.47 ns) 484.27 ns 501.28 ns 503.47 ns ``` ```js Deno.bench("event constructor no init", () => { const event = new Event("foo"); }); Deno.bench("event constructor", () => { const event = new Event("foo", { bubbles: true, cancelable: false }); }); ``` towards https://github.com/denoland/deno/issues/20167 |
||
---|---|---|
.. | ||
napi | ||
node_compat | ||
release | ||
wpt | ||
build_bench.ts | ||
build_benchmark_jsons.js | ||
copyright_checker.js | ||
core_import_map.json | ||
cut_a_release.md | ||
deno.lock.json | ||
flamebench.js | ||
format.js | ||
lint.js | ||
README.md | ||
update_typescript.md | ||
upload_wptfyi.js | ||
util.js | ||
verify_pr_title.js | ||
wpt.ts |
Tools
Documentation for various tooling in support of Deno development.
format.js
This script will format the code (currently using dprint, rustfmt). It is a prerequisite to run this before code check in.
To run formatting:
deno run --allow-read --allow-write --allow-run --unstable ./tools/format.js
lint.js
This script will lint the code base (currently using dlint, clippy). It is a prerequisite to run this before code check in.
To run linting:
deno run --allow-read --allow-write --allow-run --unstable ./tools/lint.js
Tip: You can also use cargo to run the current or pending build of the deno executable
cargo run -- run --allow-read --allow-write --allow-run --unstable ./tools/<script>
flamebench.js
flamebench.js
facilitates profiling and generating flamegraphs from
benchmarks.
General usage:
❯ ./tools/flamebench.js
flamebench <bench_name> [bench_filter]
Available benches:
op_baseline
ser
de
To profile the op_baseline
bench, run ./tools/flamebench.js op_baseline
,
this will run all 3 benches in `op_baseline.
Often when profiling/optimizing, you'll want to focus on a specific sub-bench,
flamebench
supports a bench/test filter arg like the regular cargo commands.
So you can simply run ./tools/flamebench.js op_baseline bench_op_async
or
./tools/flamebench.js op_baseline bench_op_nop
to profile specific benches.
Tip: the [bench_filter]
argument doesn't have to be an exact bench name, you
can use a shorthand or a partial match to profile a group of benches, e.g:
./tools/flamebench.js de v8
copyright_checker.js
copyright_checker.js
is used to check copyright headers in the codebase.
To run the copyright checker:
deno run --allow-read --allow-run --unstable ./tools/copyright_checker.js
Then it will check all code files in the repository and report any files that are not properly licensed.