krofdrakula
krofdrakula
DDeno
Created by krofdrakula on 5/5/2025 in #help
Recently upgraded `deno` and am on a newer version than is available
Looks like there might have been a problem when publishing versions; when I ran deno upgrade recently, it upgraded my deno version to 2.4.0, but it looks like the real latest version is 2.3.1 and the version was supposed to be 2.3.0 when that update went out. Is there anything I should be worried about since deno --version currently reports 2.4.0 when it comes to future releases? Using deno upgrade 2.3.0 didn't install the previous version, it kept it at 2.4.0. I'm using the stable channel.
3 replies
DDeno
Created by krofdrakula on 1/30/2023 in #help
Setting up complex values for `Deno.bench` function runs
i'm currently exploring the bench tools in Deno and have come across a case where i can't seem to be able to implement. in the simplest case, let's say we wanted to compare two functions that mutate a given array, but that array is nontrivially large:
const a = <T>(arr: T[], ...items:T[]): T[] => {};
const b = <T>(arr: T[], ...items:T[]): T[] => {};

const getSample = () => {
const sample:number[] = [];
for (let i = 0; i < 1e6; i++) sample.push(i);
return sample;
};

Deno.bench('a', () => {
const data = getSample();
a(data, -1);
});

Deno.bench('b', () => {
const data = getSample();
b(data, -1);
});
const a = <T>(arr: T[], ...items:T[]): T[] => {};
const b = <T>(arr: T[], ...items:T[]): T[] => {};

const getSample = () => {
const sample:number[] = [];
for (let i = 0; i < 1e6; i++) sample.push(i);
return sample;
};

Deno.bench('a', () => {
const data = getSample();
a(data, -1);
});

Deno.bench('b', () => {
const data = getSample();
b(data, -1);
});
the problem with these benches is that they build the data within the benchmark function, which i do not want to measure as part of the benchmark. i couldn't find an analog prerun function in the docs, is there a way to pass data created outside the measured function to it? something like:
Deno.bench({
name: 'a',
prerun: () => getSample(),
fn(data) { // `data` === `ReturnType<typeof prerun>`
a(data, -1);
}
});
Deno.bench({
name: 'a',
prerun: () => getSample(),
fn(data) { // `data` === `ReturnType<typeof prerun>`
a(data, -1);
}
});
9 replies