claude-flow
Version:
Ruflo - Enterprise AI agent orchestration for Claude Code. Deploy 60+ specialized agents in coordinated swarms with self-learning, fault-tolerant consensus, vector memory, and MCP integration
63 lines (54 loc) โข 2.23 kB
text/typescript
/**
* Quick Integration Test
*
* Verifies @ruvector/attention integration is working correctly.
* Run with: npx tsx v3/@claude-flow/performance/src/examples/quick-test.ts
*/
import {
FlashAttention,
createFlashAttentionOptimizer,
quickBenchmark,
} from '../attention-integration.js';
async function quickTest() {
console.log('\n๐งช Quick Integration Test\n');
console.log('โ'.repeat(60));
try {
// Test 1: Direct @ruvector/attention usage
console.log('\nโ Test 1: Direct @ruvector/attention usage');
const flash = new FlashAttention(128, 64); // dim, blockSize
const query = new Float32Array(128).fill(1.0);
const keys = [new Float32Array(128).fill(1.0)];
const values = [new Float32Array(128).fill(1.0)];
const result = flash.compute(query, keys, values);
console.log(` Result: Float32Array[${result.length}]`);
// Test 2: V3 optimizer
console.log('\nโ Test 2: V3 FlashAttentionOptimizer');
const optimizer = createFlashAttentionOptimizer(128);
const output = optimizer.optimize({
query: new Float32Array(128).fill(1.0),
keys: Array.from({ length: 50 }, () => new Float32Array(128).fill(1.0)),
values: Array.from({ length: 50 }, () => new Float32Array(128).fill(1.0)),
});
console.log(` Execution time: ${output.executionTimeMs.toFixed(3)}ms`);
console.log(` Runtime: ${output.runtime}`);
// Test 3: Quick benchmark
console.log('\nโ Test 3: Quick benchmark');
const benchResult = quickBenchmark(256);
console.log(` Flash: ${benchResult.flashAttention.averageTimeMs.toFixed(3)}ms`);
console.log(` Baseline: ${benchResult.baseline.averageTimeMs.toFixed(3)}ms`);
console.log(` Speedup: ${benchResult.speedup.toFixed(2)}x`);
console.log(` Meets target: ${benchResult.meetsTarget ? 'YES โ' : 'NO โ'}`);
console.log('\n' + 'โ'.repeat(60));
console.log('\nโ
All tests passed! Integration working correctly.\n');
return true;
} catch (error) {
console.error('\nโ Test failed:', error);
console.log('\n' + 'โ'.repeat(60) + '\n');
return false;
}
}
// Run test
quickTest().then(success => {
process.exit(success ? 0 : 1);
});