deno_cache icon indicating copy to clipboard operation
deno_cache copied to clipboard

perf: reduce allocations in url_to_filename

Open dsherret opened this issue 1 year ago • 0 comments

I noticed this method was taking 3% of execution in a benchmark I ran and it seemed to mostly be because of unnecessary allocations.

Built on top of https://github.com/denoland/deno_cache_dir/pull/54 -- waiting for that one to merge first

Before:
main                      fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ url_to_filename_bench  1.199 µs      │ 27.09 µs      │ 1.299 µs      │ 1.578 µs      │ 100     │ 100

After:
main                      fastest       │ slowest       │ median        │ mean          │ samples │ iters
╰─ url_to_filename_bench  1.099 µs      │ 16.89 µs      │ 1.199 µs      │ 1.346 µs      │ 100     │ 100

dsherret avatar Aug 21 '24 20:08 dsherret