Skip to content

Instantly share code, notes, and snippets.

@gkucmierz
Created January 13, 2025 10:54
Show Gist options
  • Save gkucmierz/b33f275fc3e8886fef1fd112003ac4b1 to your computer and use it in GitHub Desktop.
Save gkucmierz/b33f275fc3e8886fef1fd112003ac4b1 to your computer and use it in GitHub Desktop.
// https://instacode.app/run/FAYw9gdgzgLgBAFQJIFkCiBlOBeOBGAUwHYBuUSWODBAJRzgHIEALASyjgAcAnMAKwIh4AdwCGHbgVEAbVgC8CAEzjiuo7vDAAzOAFsAnio2sQ0ggzLlo8SZ2miQBegG1gcOLG44AfB5jcAOlt7RwBBaWkACgZGABpGAFoGAEpYtz8vbF9PIII7BwJIgHo4IoBzeIYk1PTPHwzc-MdigB0AdXLK6rSAXUtggoDdUU5IyK0IeNZk+oBvdPBrOBg8egBqCAJhOAARURgCMnctMC9Is3hWegAGEjgrgB5EVEw7tbXpuHn3Y4hI6hoySOcAAvgsKPAYAAmdabbZ7A7AxZQMBmALSMBlSIAAwA8pwYKxIHAACSzVgggBcy1YugI1LJ0ISKxB2KBwBB7OAQA
const TIMES = 1e7;
const STR = 'This project was realized as part of my article';
const replace = [
str => str.replaceAll(' ', '-'),
str => str.replace(/ /g, '-'),
str => str.replace(/\W/g, '-'),
];
replace.map((fn, i) => {
const t1 = +new Date;
for (let i = 0; i < TIMES; ++i) {
fn(STR);
}
const t2 = +new Date;
console.log(`Option ${i}: time: ${t2-t1}`);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment