* Benchmarks authentication delay functionality
()
| 326 | * Benchmarks authentication delay functionality |
| 327 | */ |
| 328 | function benchmarkAuthDelay () { |
| 329 | console.log("\n📊 Authentication Delay Performance"); |
| 330 | console.log("-".repeat(40)); |
| 331 | |
| 332 | const suite = new Benchmark.Suite(); |
| 333 | |
| 334 | // Mock delay function (without actual setTimeout for benchmarking) |
| 335 | const mockDelay = (fn, delay) => { |
| 336 | if (delay === 0) { |
| 337 | fn(); |
| 338 | } else { |
| 339 | // In benchmark, we just simulate the delay logic without waiting |
| 340 | const randomDelay = Math.floor(Math.random() * delay) + 1; // eslint-disable-line no-unused-vars |
| 341 | fn(); // Execute immediately for benchmarking |
| 342 | } |
| 343 | }; |
| 344 | |
| 345 | const authFunction = () => { |
| 346 | // Mock authentication logic |
| 347 | return Math.random() > 0.5; // Random success/failure |
| 348 | }; |
| 349 | |
| 350 | suite |
| 351 | .add("Auth Delay - No delay (0ms)", () => { |
| 352 | mockDelay(authFunction, 0); |
| 353 | }) |
| 354 | .add("Auth Delay - Small delay (100ms)", () => { |
| 355 | mockDelay(authFunction, 100); |
| 356 | }) |
| 357 | .add("Auth Delay - Medium delay (500ms)", () => { |
| 358 | mockDelay(authFunction, 500); |
| 359 | }) |
| 360 | .add("Auth Delay - Large delay (1000ms)", () => { |
| 361 | mockDelay(authFunction, 1000); |
| 362 | }) |
| 363 | .on("cycle", event => { |
| 364 | console.log(` ${String(event.target)}`); |
| 365 | }) |
| 366 | .on("complete", function () { |
| 367 | console.log(" Note: Delay simulation only - actual delays not applied in benchmark"); |
| 368 | }) |
| 369 | .run(); |
| 370 | } |
| 371 | |
| 372 | /** |
| 373 | * Benchmarks session-based authentication |