Page MenuHomePhorge

test_minicoro_concurrent.cjs
No OneTemporary

Size
862 B
Referenced Files
None
Subscribers
None

test_minicoro_concurrent.cjs

// Test that multiple async functions run concurrently
async function delay(ms, name) {
const start = Date.now();
await new Promise(resolve => setTimeout(resolve, ms));
const elapsed = Date.now() - start;
console.log(`${name}: ${elapsed}ms`);
return elapsed;
}
console.log("Testing concurrent async/await with minicoro");
const globalStart = Date.now();
// Start both async functions - they should run concurrently
delay(100, "Task A (100ms)");
delay(50, "Task B (50ms)");
// Wait for both to complete
setTimeout(() => {
const total = Date.now() - globalStart;
console.log(`\nTotal time: ${total}ms`);
// If concurrent: ~105ms (max of the two)
// If sequential: ~155ms (sum of the two)
if (total < 130) {
console.log("✓ PASS: Tasks ran concurrently!");
} else {
console.log("✗ FAIL: Tasks ran sequentially");
}
}, 120);

File Metadata

Mime Type
text/plain
Expires
Wed, Jun 17, 1:37 PM (1 d, 22 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
523794
Default Alt Text
test_minicoro_concurrent.cjs (862 B)

Event Timeline