Hello,
I’ve noticed the browser.tabs.duplicate(tab.id)
method takes about 400ms to complete, which is like 20 times more compare to browser.tabs.create(tab.url)
which takes about 20ms.
Is there a reason for that? I know it’s not the same thing but it’s hard to believe there is a performance reason behind it related to copying tab history (even when there is none).
Try yourself:
const HighResolutionTimer = (name = '', startNow = false) => {
let startTime, stopTime;
if (startNow) start();
return {
start: start,
stop: stop
};
function start() {
startTime = performance.now();
}
function stop(message = '') {
stopTime = performance.now();
console.warn(`${name} ${message} time: ${stopTime - startTime}`);
}
};
const tab = await browser.tabs.getCurrent();
const p = HighResolutionTimer('Speed test', true);
browser.tabs.duplicate(tab.id).then(() => p.stop('duplicate'));
browser.tabs.create({url: tab.url, active: true}).then(() => p.stop('create'));