|
| 1 | +#!/bin/bash |
| 2 | +# Performance test script for emacs-aichat-skintwin |
| 3 | +# This script is called by the performance-tests.yml workflow |
| 4 | + |
| 5 | +set -e |
| 6 | + |
| 7 | +# Configuration |
| 8 | +PERFORMANCE_THRESHOLD="${PERFORMANCE_THRESHOLD:-5.0}" |
| 9 | + |
| 10 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" |
| 11 | +cd "$SCRIPT_DIR/../.." |
| 12 | + |
| 13 | +echo "=== Performance Test Suite ===" |
| 14 | +echo "Regression threshold: ${PERFORMANCE_THRESHOLD}s" |
| 15 | + |
| 16 | +# Test 1: AtomSpace operations |
| 17 | +echo "" |
| 18 | +echo "Test 1: AtomSpace Operations (100 iterations)" |
| 19 | +cask emacs --batch -L . \ |
| 20 | + --eval "(require 'aichat-opencog)" \ |
| 21 | + --eval "(benchmark-run 100 \ |
| 22 | + (aichat-opencog-add-atom 'ConceptNode \"test-concept\"))" \ |
| 23 | + --eval "(message \"AtomSpace benchmark complete\")" |
| 24 | + |
| 25 | +# Test 2: ECAN spreading |
| 26 | +echo "" |
| 27 | +echo "Test 2: ECAN Spreading (10 iterations)" |
| 28 | +cask emacs --batch -L . \ |
| 29 | + --eval "(require 'aichat-ecan)" \ |
| 30 | + --eval "(progn \ |
| 31 | + (require 'aichat-opencog) \ |
| 32 | + (dotimes (i 100) \ |
| 33 | + (aichat-opencog-add-atom 'ConceptNode (format \"concept-%d\" i))) \ |
| 34 | + (message \"Timing ECAN spreading...\") \ |
| 35 | + (benchmark-run 10 \ |
| 36 | + (aichat-ecan-spread-importance aichat-opencog-kb)))" \ |
| 37 | + --eval "(message \"ECAN benchmark complete\")" |
| 38 | + |
| 39 | +# Test 3: PLN reasoning |
| 40 | +echo "" |
| 41 | +echo "Test 3: PLN Reasoning (50 iterations)" |
| 42 | +cask emacs --batch -L . \ |
| 43 | + --eval "(require 'aichat-pln)" \ |
| 44 | + --eval "(benchmark-run 50 \ |
| 45 | + (aichat-pln-deduction \ |
| 46 | + (cons 0.8 0.9) \ |
| 47 | + (cons 0.7 0.85)))" \ |
| 48 | + --eval "(message \"PLN benchmark complete\")" |
| 49 | + |
| 50 | +# Test 4: Memory usage |
| 51 | +echo "" |
| 52 | +echo "Test 4: Memory Usage (1000 atoms)" |
| 53 | +cask emacs --batch -L . \ |
| 54 | + --eval "(require 'aichat-opencog)" \ |
| 55 | + --eval "(require 'aichat-ecan)" \ |
| 56 | + --eval "(require 'aichat-pln)" \ |
| 57 | + --eval "(garbage-collect)" \ |
| 58 | + --eval "(let ((before (memory-use-counts))) \ |
| 59 | + (dotimes (i 1000) \ |
| 60 | + (aichat-opencog-add-atom 'ConceptNode (format \"test-%d\" i))) \ |
| 61 | + (garbage-collect) \ |
| 62 | + (let ((after (memory-use-counts))) \ |
| 63 | + (message \"Memory usage - Before: %S, After: %S\" before after)))" |
| 64 | + |
| 65 | +# Test 5: Large knowledge base stress test |
| 66 | +echo "" |
| 67 | +echo "Test 5: Large KB Stress Test (5000 atoms)" |
| 68 | +cask emacs --batch -L . \ |
| 69 | + --eval "(require 'aichat-opencog)" \ |
| 70 | + --eval "(message \"Creating large knowledge base...\") \ |
| 71 | + (benchmark-run 1 \ |
| 72 | + (dotimes (i 5000) \ |
| 73 | + (aichat-opencog-add-atom 'ConceptNode (format \"concept-%d\" i)) \ |
| 74 | + (when (> i 0) \ |
| 75 | + (aichat-opencog-add-link 'InheritanceLink \ |
| 76 | + (list (format \"concept-%d\" i) \ |
| 77 | + (format \"concept-%d\" (random i)))))))" \ |
| 78 | + --eval "(message \"Large KB test complete\")" |
| 79 | + |
| 80 | +# Test 6: Regression detection |
| 81 | +echo "" |
| 82 | +echo "Test 6: Regression Detection (1000 atoms baseline)" |
| 83 | +cask emacs --batch -L . \ |
| 84 | + --eval "(require 'aichat-opencog)" \ |
| 85 | + --eval "(let ((start (current-time))) \ |
| 86 | + (dotimes (i 1000) \ |
| 87 | + (aichat-opencog-add-atom 'ConceptNode (format \"test-%d\" i))) \ |
| 88 | + (let ((elapsed (float-time (time-subtract (current-time) start)))) \ |
| 89 | + (message \"Baseline: 1000 atoms in %.3f seconds\" elapsed) \ |
| 90 | + (when (> elapsed ${PERFORMANCE_THRESHOLD}) \ |
| 91 | + (message \"WARNING: Performance regression detected!\") \ |
| 92 | + (message \"Expected: < ${PERFORMANCE_THRESHOLD}s, Actual: %.3fs\" elapsed))))" |
| 93 | + |
| 94 | +echo "" |
| 95 | +echo "=== Performance Tests Complete ===" |
0 commit comments