CRITICAL CHECKPOINT - DO NOT PUSH TO GITHUB Recovery Status: - Successfully recovered brainy.ts from compiled JavaScript - All core v3.0 API methods functional (add, get, update, delete, relate, find, etc.) - Neural subsystem intact (562KB embedded patterns, NLP working) - Augmentation pipeline operational (20+ augmentations) - HNSW clustering system complete - Triple Intelligence compiled (needs constructor fix) - Test suite validates functionality Changes preserved: - 898 files with changes from last 3 days - 144,475 insertions - All augmentation improvements - All test coverage enhancements - Complete v3.0 feature set This is a LOCAL checkpoint only - contains recovered work after corruption incident. Created backup in .backups/brainy-full-20250910-151314.tar.gz Branch: recovery-checkpoint-20250910-151433 Date: Wed Sep 10 03:18:04 PM PDT 2025
57 lines
No EOL
1.8 KiB
JavaScript
57 lines
No EOL
1.8 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
import { BrainyData } from './dist/index.js'
|
|
|
|
async function testMemoryUsage() {
|
|
console.log('Testing memory usage...\n')
|
|
|
|
// Log memory before
|
|
const memBefore = process.memoryUsage()
|
|
console.log('Memory before:', {
|
|
rss: Math.round(memBefore.rss / 1024 / 1024) + ' MB',
|
|
heapUsed: Math.round(memBefore.heapUsed / 1024 / 1024) + ' MB'
|
|
})
|
|
|
|
const brain = new BrainyData({
|
|
storage: { forceMemoryStorage: true }
|
|
})
|
|
await brain.init()
|
|
console.log('✅ Brain initialized\n')
|
|
|
|
// Log memory after init
|
|
const memAfterInit = process.memoryUsage()
|
|
console.log('Memory after init:', {
|
|
rss: Math.round(memAfterInit.rss / 1024 / 1024) + ' MB',
|
|
heapUsed: Math.round(memAfterInit.heapUsed / 1024 / 1024) + ' MB',
|
|
delta: Math.round((memAfterInit.heapUsed - memBefore.heapUsed) / 1024 / 1024) + ' MB'
|
|
})
|
|
|
|
// Add some data WITHOUT using find()
|
|
console.log('\n📝 Adding data...')
|
|
for (let i = 0; i < 5; i++) {
|
|
await brain.addNoun(`Item ${i}`, { metadata: { index: i } })
|
|
}
|
|
console.log('✅ Added 5 items\n')
|
|
|
|
// Now try search (not find)
|
|
console.log('🔍 Testing search...')
|
|
const results = await brain.search('Item', { limit: 3 })
|
|
console.log(`Found ${results.length} results\n`)
|
|
|
|
// Log memory after search
|
|
const memAfterSearch = process.memoryUsage()
|
|
console.log('Memory after search:', {
|
|
rss: Math.round(memAfterSearch.rss / 1024 / 1024) + ' MB',
|
|
heapUsed: Math.round(memAfterSearch.heapUsed / 1024 / 1024) + ' MB',
|
|
delta: Math.round((memAfterSearch.heapUsed - memAfterInit.heapUsed) / 1024 / 1024) + ' MB'
|
|
})
|
|
|
|
await brain.shutdown()
|
|
console.log('\n✅ Test complete!')
|
|
process.exit(0)
|
|
}
|
|
|
|
testMemoryUsage().catch(err => {
|
|
console.error('❌ Error:', err.message)
|
|
process.exit(1)
|
|
}) |