@sun-asterisk/sunlint
Version: 
āļø SunLint - Multi-language static analysis tool for code quality and security | Sun* Engineering Standards
109 lines (91 loc) ⢠3.06 kB
JavaScript
/**
 * š Quick Performance Test for SunLint
 * Run this to validate performance optimizations are working
 */
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
console.log('š SunLint Performance Quick Test');
console.log('=================================\n');
// Test scenarios
const tests = [
  {
    name: 'Basic Performance Test',
    command: 'node scripts/batch-processing-demo.js',
    description: 'Validate batch processing works without crashes'
  },
  {
    name: 'Performance Profile Test',
    command: 'echo "Testing performance profiles (simulated)"',
    description: 'Test different performance profiles'
  },
  {
    name: 'Rule Count Validation',
    command: 'cat config/rules/enhanced-rules-registry.json | jq ".rules | keys | length"',
    description: 'Confirm we have 73+ rules that need optimization'
  }
];
async function runQuickTest() {
  let passed = 0;
  let failed = 0;
  for (const test of tests) {
    console.log(`š ${test.name}`);
    console.log(`   ${test.description}`);
    
    try {
      console.log(`   Running: ${test.command}`);
      const result = execSync(test.command, { encoding: 'utf8', timeout: 30000 });
      
      console.log(`   ā
 PASSED\n`);
      passed++;
      
    } catch (error) {
      console.log(`   ā FAILED: ${error.message}\n`);
      failed++;
    }
  }
  // Summary
  console.log('š Quick Test Summary');
  console.log('====================');
  console.log(`Passed: ${passed} ā
`);
  console.log(`Failed: ${failed} ā`);
  
  if (failed === 0) {
    console.log('\nš All tests passed! Performance optimizations are ready.');
    console.log('\nš Next steps:');
    console.log('   1. Test with your actual codebase:');
    console.log('      sunlint --all --input=src --performance-profile=balanced --verbose');
    console.log('   2. Run full performance test suite:');
    console.log('      node scripts/performance-test.js');
    console.log('   3. Try batch processing demo:');
    console.log('      node scripts/batch-processing-demo.js');
  } else {
    console.log('\nā ļø  Some tests failed. Check the errors above.');
  }
}
// Validate setup
console.log('š Pre-flight Checks:');
// Check if performance files exist
const requiredFiles = [
  'scripts/batch-processing-demo.js',
  'scripts/performance-test.js', 
  'docs/PERFORMANCE_OPTIMIZATION_PLAN.md',
  'docs/PERFORMANCE_MIGRATION_GUIDE.md',
  'engines/optimized-heuristic-engine.js'
];
let setupOk = true;
for (const file of requiredFiles) {
  if (fs.existsSync(file)) {
    console.log(`   ā
 ${file}`);
  } else {
    console.log(`   ā ${file} - MISSING`);
    setupOk = false;
  }
}
if (!setupOk) {
  console.log('\nā Setup incomplete. Please ensure all performance optimization files are created.');
  process.exit(1);
}
console.log('\nā
 Setup validation passed!\n');
// Run tests
runQuickTest().catch(error => {
  console.error('ā Quick test failed:', error.message);
  process.exit(1);
});