Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions benchmark.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { askCrystalBall } from './lib/magic.ts';

async function main() {
const start = performance.now();
for (let i = 0; i < 5; i++) {
await askCrystalBall('test');
}
const end = performance.now();
console.log(`Execution time for 5 iterations: ${(end - start).toFixed(2)} ms`);
console.log(`Average time per iteration: ${((end - start) / 5).toFixed(2)} ms`);
}

main();
3 changes: 0 additions & 3 deletions lib/magic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ export async function askCrystalBall(_productName: string) {
`Kula zrobiła się mętna... Jeśli to w ogóle u nas jest, to pewnie służy teraz jako podpórka do kiwającego się stołu na zapleczu. Kto wie? Tylko szef wie!`
];

// Symulacja "myślenia" magicznej kuli (opóźnienie dla lepszego efektu w UI)
await new Promise(resolve => setTimeout(resolve, 800));

// Losujemy jeden z żartów
const randomIndex = Math.floor(Math.random() * jokes.length);
return jokes[randomIndex];
Expand Down