MCPcopy Create free account
hub / github.com/Orgnise/webapp / testConnectionPooling

Function testConnectionPooling

scripts/db/test-optimization.ts:89–117  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

87}
88
89async function testConnectionPooling() {
90 console.log("\n🔄 Testing connection pooling...");
91
92 try {
93 // Test multiple concurrent connections
94 const promises = Array.from({ length: 5 }, async (_, i) => {
95 const client = await mongoDb;
96 const db = client.db(process.env.DATABASE_NAME || 'pulse-db');
97 const startTime = Date.now();
98
99 // Simple operation
100 await db.command({ ping: 1 });
101
102 const duration = Date.now() - startTime;
103 console.log(` Connection ${i + 1}: ${duration}ms`);
104 return duration;
105 });
106
107 const results = await Promise.all(promises);
108 const avgTime = results.reduce((a, b) => a + b, 0) / results.length;
109
110 console.log(` 📊 Average connection time: ${avgTime.toFixed(2)}ms`);
111 console.log(" ✅ Connection pooling working correctly");
112
113 } catch (error) {
114 console.error(" ❌ Connection pooling test failed:", error);
115 throw error;
116 }
117}
118
119async function main() {
120 try {

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…