chore: delete unused trash explorer documentation files
This commit is contained in:
@@ -0,0 +1,101 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const BASE_URL = process.env.BASE_URL || 'http://localhost:4000';
|
||||
|
||||
async function testPagination() {
|
||||
console.log('🧪 Testing Pagination Performance\n');
|
||||
|
||||
try {
|
||||
// Test 1: First page
|
||||
console.log('📄 Test 1: Loading first page...');
|
||||
const start1 = performance.now();
|
||||
const response1 = await fetch(`${BASE_URL}/api/vault/metadata/paginated?limit=50`);
|
||||
const data1 = await response1.json();
|
||||
const time1 = performance.now() - start1;
|
||||
|
||||
if (!response1.ok) {
|
||||
console.error('❌ Failed to load first page:', data1);
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(`✅ First page: ${data1.items.length} items in ${time1.toFixed(2)}ms`);
|
||||
console.log(`📊 Total available: ${data1.total} items`);
|
||||
console.log(` Has more: ${data1.hasMore}`);
|
||||
console.log(` Next cursor: ${data1.nextCursor}\n`);
|
||||
|
||||
// Test 2: Pagination through 5 pages
|
||||
console.log('📜 Test 2: Simulating scroll through 5 pages...');
|
||||
let totalTime = 0;
|
||||
let totalItems = 0;
|
||||
let cursor = null;
|
||||
|
||||
for (let page = 0; page < 5; page++) {
|
||||
const start = performance.now();
|
||||
const params = new URLSearchParams({ limit: '50' });
|
||||
if (cursor !== null) params.set('cursor', cursor.toString());
|
||||
|
||||
const response = await fetch(`${BASE_URL}/api/vault/metadata/paginated?${params}`);
|
||||
const data = await response.json();
|
||||
const time = performance.now() - start;
|
||||
|
||||
if (!response.ok) {
|
||||
console.error(`❌ Failed to load page ${page + 1}:`, data);
|
||||
break;
|
||||
}
|
||||
|
||||
totalTime += time;
|
||||
totalItems += data.items.length;
|
||||
cursor = data.nextCursor;
|
||||
|
||||
console.log(` Page ${page + 1}: ${data.items.length} items in ${time.toFixed(2)}ms`);
|
||||
|
||||
if (!data.hasMore) {
|
||||
console.log(` (End of list reached)\n`);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`\n📊 Pagination Results:`);
|
||||
console.log(` Total items loaded: ${totalItems}`);
|
||||
console.log(` Total time: ${totalTime.toFixed(2)}ms`);
|
||||
console.log(` Average per page: ${(totalTime / 5).toFixed(2)}ms`);
|
||||
console.log(` Memory efficient: Only ${totalItems} items in memory\n`);
|
||||
|
||||
// Test 3: Search with pagination
|
||||
console.log('🔍 Test 3: Search with pagination...');
|
||||
const searchStart = performance.now();
|
||||
const searchResponse = await fetch(`${BASE_URL}/api/vault/metadata/paginated?limit=50&search=test`);
|
||||
const searchData = await searchResponse.json();
|
||||
const searchTime = performance.now() - searchStart;
|
||||
|
||||
if (!searchResponse.ok) {
|
||||
console.error('❌ Search failed:', searchData);
|
||||
} else {
|
||||
console.log(`✅ Search results: ${searchData.items.length} items in ${searchTime.toFixed(2)}ms`);
|
||||
console.log(` Total matches: ${searchData.total}`);
|
||||
console.log(` Has more: ${searchData.hasMore}\n`);
|
||||
}
|
||||
|
||||
// Test 4: Large cursor offset
|
||||
console.log('⏭️ Test 4: Large cursor offset...');
|
||||
const largeOffsetStart = performance.now();
|
||||
const largeOffsetResponse = await fetch(`${BASE_URL}/api/vault/metadata/paginated?limit=50&cursor=1000`);
|
||||
const largeOffsetData = await largeOffsetResponse.json();
|
||||
const largeOffsetTime = performance.now() - largeOffsetStart;
|
||||
|
||||
if (!largeOffsetResponse.ok) {
|
||||
console.error('❌ Large offset failed:', largeOffsetData);
|
||||
} else {
|
||||
console.log(`✅ Large offset (cursor=1000): ${largeOffsetData.items.length} items in ${largeOffsetTime.toFixed(2)}ms`);
|
||||
console.log(` Has more: ${largeOffsetData.hasMore}\n`);
|
||||
}
|
||||
|
||||
console.log('✅ All tests completed successfully!\n');
|
||||
|
||||
} catch (error) {
|
||||
console.error('❌ Test failed:', error);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
testPagination();
|
||||
@@ -0,0 +1,113 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const BASE_URL = process.env.BASE_URL || 'http://localhost:4000';
|
||||
|
||||
async function testMetadataEndpoint() {
|
||||
console.log('\n=== Testing /api/vault/metadata (Metadata-First) ===');
|
||||
|
||||
try {
|
||||
const start = performance.now();
|
||||
const response = await fetch(`${BASE_URL}/api/vault/metadata`);
|
||||
const data = await response.json();
|
||||
const duration = performance.now() - start;
|
||||
|
||||
const payloadSize = JSON.stringify(data).length;
|
||||
const payloadSizeMB = (payloadSize / 1024 / 1024).toFixed(2);
|
||||
const payloadSizeKB = (payloadSize / 1024).toFixed(2);
|
||||
|
||||
console.log(`✓ Loaded ${data.length} notes in ${duration.toFixed(2)}ms`);
|
||||
console.log(`✓ Payload size: ${payloadSizeMB}MB (${payloadSizeKB}KB)`);
|
||||
console.log(`✓ Average per note: ${(payloadSize / data.length).toFixed(0)} bytes`);
|
||||
|
||||
return { count: data.length, duration, payloadSize };
|
||||
} catch (error) {
|
||||
console.error('✗ Error:', error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function testOldVaultEndpoint() {
|
||||
console.log('\n=== Testing /api/vault (Full Load - OLD) ===');
|
||||
|
||||
try {
|
||||
const start = performance.now();
|
||||
const response = await fetch(`${BASE_URL}/api/vault`);
|
||||
const data = await response.json();
|
||||
const duration = performance.now() - start;
|
||||
|
||||
const payloadSize = JSON.stringify(data).length;
|
||||
const payloadSizeMB = (payloadSize / 1024 / 1024).toFixed(2);
|
||||
|
||||
console.log(`✓ Loaded ${data.notes?.length || 0} notes in ${duration.toFixed(2)}ms`);
|
||||
console.log(`✓ Payload size: ${payloadSizeMB}MB`);
|
||||
console.log(`✓ Average per note: ${(payloadSize / (data.notes?.length || 1)).toFixed(0)} bytes`);
|
||||
|
||||
return { count: data.notes?.length || 0, duration, payloadSize };
|
||||
} catch (error) {
|
||||
console.error('✗ Error:', error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function testFileListEndpoint() {
|
||||
console.log('\n=== Testing /api/files/list (Meilisearch Metadata) ===');
|
||||
|
||||
try {
|
||||
const start = performance.now();
|
||||
const response = await fetch(`${BASE_URL}/api/files/list`);
|
||||
const data = await response.json();
|
||||
const duration = performance.now() - start;
|
||||
|
||||
const payloadSize = JSON.stringify(data).length;
|
||||
const payloadSizeMB = (payloadSize / 1024 / 1024).toFixed(2);
|
||||
|
||||
console.log(`✓ Loaded ${data.length} files in ${duration.toFixed(2)}ms`);
|
||||
console.log(`✓ Payload size: ${payloadSizeMB}MB`);
|
||||
console.log(`✓ Average per file: ${(payloadSize / data.length).toFixed(0)} bytes`);
|
||||
|
||||
return { count: data.length, duration, payloadSize };
|
||||
} catch (error) {
|
||||
console.error('✗ Error:', error.message);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
async function runComparison() {
|
||||
console.log('╔════════════════════════════════════════════════════════════╗');
|
||||
console.log('║ Performance Comparison: Metadata-First vs Full Load ║');
|
||||
console.log('╚════════════════════════════════════════════════════════════╝');
|
||||
|
||||
const metadata = await testMetadataEndpoint();
|
||||
const fileList = await testFileListEndpoint();
|
||||
const full = await testOldVaultEndpoint();
|
||||
|
||||
if (metadata && full) {
|
||||
console.log('\n╔════════════════════════════════════════════════════════════╗');
|
||||
console.log('║ Summary & Improvements ║');
|
||||
console.log('╚════════════════════════════════════════════════════════════╝');
|
||||
|
||||
const speedImprovement = ((full.duration / metadata.duration - 1) * 100).toFixed(0);
|
||||
const sizeImprovement = ((full.payloadSize / metadata.payloadSize - 1) * 100).toFixed(0);
|
||||
|
||||
console.log(`\n📊 Metadata Endpoint (NEW):`);
|
||||
console.log(` Duration: ${metadata.duration.toFixed(2)}ms`);
|
||||
console.log(` Payload: ${(metadata.payloadSize / 1024).toFixed(0)}KB`);
|
||||
|
||||
if (fileList) {
|
||||
console.log(`\n📊 Files List Endpoint (Meilisearch):`);
|
||||
console.log(` Duration: ${fileList.duration.toFixed(2)}ms`);
|
||||
console.log(` Payload: ${(fileList.payloadSize / 1024).toFixed(0)}KB`);
|
||||
}
|
||||
|
||||
console.log(`\n📊 Full Vault Endpoint (OLD):`);
|
||||
console.log(` Duration: ${full.duration.toFixed(2)}ms`);
|
||||
console.log(` Payload: ${(full.payloadSize / 1024 / 1024).toFixed(2)}MB`);
|
||||
|
||||
console.log(`\n✅ Performance Improvements:`);
|
||||
console.log(` Speed: ${speedImprovement}% faster`);
|
||||
console.log(` Size: ${sizeImprovement}% smaller`);
|
||||
console.log(` Startup time reduced from ~${full.duration.toFixed(0)}ms to ~${metadata.duration.toFixed(0)}ms`);
|
||||
}
|
||||
}
|
||||
|
||||
runComparison().catch(console.error);
|
||||
Reference in New Issue
Block a user