-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathquick_optimized_test.js
More file actions
80 lines (65 loc) · 2.86 KB
/
quick_optimized_test.js
File metadata and controls
80 lines (65 loc) · 2.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import { queryStream } from './utils/query.js';
// Quick test with optimized system
class QuickTestResponse {
constructor() {
this.chunks = [];
this.startTime = Date.now();
}
write(data) {
const elapsed = Date.now() - this.startTime;
this.chunks.push({ time: elapsed, data: data.trim() });
console.log(`[${elapsed}ms] ${data.trim()}`);
}
end() {
console.log(`\n⏱️ Total time: ${Date.now() - this.startTime}ms`);
console.log(`📦 Total chunks: ${this.chunks.length}`);
}
}
async function quickOptimizedTest() {
console.log('🚀 QUICK OPTIMIZED SYSTEM TEST');
console.log('=' .repeat(50));
const mockRes = new QuickTestResponse();
const testMessage = "I feel anxious about my upcoming presentation tomorrow.";
console.log(`📝 Testing: "${testMessage}"`);
console.log('Starting optimized queryStream...\n');
try {
const result = await Promise.race([
queryStream(testMessage, mockRes, {
userId: 'quick_test',
authToken: 'test_token'
}),
new Promise((_, reject) => {
setTimeout(() => reject(new Error('Test timeout')), 25000);
})
]);
mockRes.end();
console.log('\n✅ Test completed successfully!');
console.log('📊 Result length:', result?.length || 0);
// Quick performance assessment
const totalTime = Date.now() - mockRes.startTime;
const hasWorkflow = mockRes.chunks.some(c => c.data.includes('workflow'));
const hasAgents = mockRes.chunks.some(c => c.data.includes('agent'));
const hasError = mockRes.chunks.some(c => c.data.includes('error'));
console.log('\n📊 Performance Assessment:');
console.log(`⏱️ Speed: ${totalTime < 20000 ? '✅' : '❌'} ${totalTime}ms (target: <20s)`);
console.log(`🔄 Workflow: ${hasWorkflow ? '✅' : '❌'} Agent coordination`);
console.log(`👥 Agents: ${hasAgents ? '✅' : '❌'} Agent involvement`);
console.log(`🛠️ Stability: ${!hasError ? '✅' : '❌'} Error-free execution`);
const score = (totalTime < 20000 ? 25 : 0) +
(hasWorkflow ? 25 : 0) +
(hasAgents ? 25 : 0) +
(!hasError ? 25 : 0);
console.log(`\n🎯 Quick Score: ${score}/100`);
if (score >= 80) {
console.log('🥈 EXCELLENT - Ready for full testing!');
} else if (score >= 60) {
console.log('📈 GOOD - Some optimizations working!');
} else {
console.log('🔧 NEEDS MORE WORK - Continue optimizing');
}
} catch (error) {
mockRes.end();
console.log(`\n❌ Test failed: ${error.message}`);
}
}
quickOptimizedTest();