Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const suggestSync3Test = (word: string): number => {
let start = performance.now()
nodehun3.suggestSync(word)
let end = performance.now()
return end - start
}
function (url, opts) {
performance.mark(url + " - begin")
const { fetch } = abortableFetch(nodeFetch) as any
return fetch(url, opts).then(_ => {
performance.mark(url + " - end")
const measure = () => performance.measure(_.url, url + " - begin", url + " - end")
performance.clearMarks(url + " - begin")
if(timeout)
setTimeout(measure, timeout)
else
measure()
return _
})
}
setTimeout(() => {
performance.mark('B');
performance.measure('A to B', 'A', 'B');
}, 1);
setTimeout(() => {
performance.mark('B');
performance.measure('A to B', 'A', 'B');
}, 1);
remoteDataChannel.addEventListener('message', ({ data }) => {
if (times.length < n) {
const timestamp = Number.parseFloat(data);
const time = performance.now() - timestamp;
times.push(time);
}
});
function measure(name: string, fn: () => void) {
const start = performance.now();
fn();
const time = performance.now() - start;
if (!result[name]) {
result[name] = [];
}
result[name].push(time);
//console.log(`${name} in: ${time}ms`);
return name;
}
function measure(name: string, fn: () => void) {
const start = performance.now();
fn();
const time = performance.now() - start;
if (!result[name]) {
result[name] = [];
}
result[name].push(time);
//console.log(`${name} in: ${time}ms`);
return name;
}
function measure(name: string, fn: () => void) {
const start = performance.now();
fn();
const time = performance.now() - start;
if (!result[name]) {
result[name] = [];
}
result[name].push(time);
//console.log(`${name} in: ${time}ms`);
return name;
}
function measure(name: string, fn: () => void) {
const start = performance.now();
fn();
const time = performance.now() - start;
if (!result[name]) {
result[name] = [];
}
result[name].push(time);
//console.log(`${name} in: ${time}ms`);
return name;
}
const perf = name => {
if (measures.includes(name)) {
performance.mark(`${name}_end`);
performance.measure(`${name} start to ${name} end`, name, `${name}_end`);
//let measure = performance.getEntriesByName(`${name} start to ${name} end`)[0];
//log(`${name} Done in ${(measure.duration/1000).toFixed(2)}s.`);
clearPerf(name);
}
else {
performance.mark(name);
const obs = new PerformanceObserver((list, observer) => {
console.log(list.getEntries());
observer.disconnect();
});
measures.push(name);
}
};