Files
aitbc/scripts/benchmarking/generate-report.sh
aitbc 87e524e42c feat: enhance smart contract testing and deployment
- Add comprehensive test files for core contracts (ContractRegistry, TreasuryManager, AgentMarketplaceV2, EscrowService, DynamicPricing)
- Add Foundry fuzz tests for ContractRegistry, TreasuryManager, and AgentMarketplaceV2
- Add deployment automation scripts (deploy-automation.js, verify-deployment.js, monitor-contracts.js)
- Fix Hardhat/toolbox version compatibility in package.json
- Update smart-contract-tests.yml workflow to include deployment job
2026-04-29 10:44:40 +02:00

90 lines
2.2 KiB
Bash
Executable File

#!/bin/bash
# Generate comprehensive benchmark report
set -e
BENCHMARK_DIR="/var/lib/aitbc/benchmarks"
REPORT_DIR="/var/lib/aitbc/benchmarks/reports"
REPORT_FILE="$REPORT_DIR/benchmark-report-$(date +%Y%m%d-%H%M%S).md"
echo "=== Generating Benchmark Report ==="
# Ensure directory exists
mkdir -p "$REPORT_DIR"
# Create report header
cat > "$REPORT_FILE" << EOF
# Contract Performance Benchmark Report
**Generated:** $(date -u +%Y-%m-%dT%H:%M:%SZ)
**Commit:** $(cd /opt/aitbc && git rev-parse --short HEAD)
## Summary
This report summarizes the performance benchmarks for AITBC smart contracts.
## Gas Usage Benchmarks
EOF
# Add gas usage data
LATEST_GAS=$(ls -t "$BENCHMARK_DIR"/gas-report-*.txt 2>/dev/null | head -1)
if [[ -n "$LATEST_GAS" ]]; then
echo "### Latest Gas Report" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
cat "$LATEST_GAS" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
fi
# Add execution time data
cat >> "$REPORT_FILE" << EOF
## Execution Time Benchmarks
EOF
LATEST_EXECUTION=$(ls -t "$BENCHMARK_DIR"/execution-time-*.json 2>/dev/null | head -1)
if [[ -n "$LATEST_EXECUTION" ]]; then
echo "### Latest Execution Time Report" >> "$REPORT_FILE"
echo "\`\`\`json" >> "$REPORT_FILE"
cat "$LATEST_EXECUTION" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
fi
# Add throughput data
cat >> "$REPORT_FILE" << EOF
## Throughput Benchmarks
EOF
LATEST_THROUGHPUT=$(ls -t "$BENCHMARK_DIR"/throughput-*.json 2>/dev/null | head -1)
if [[ -n "$LATEST_THROUGHPUT" ]]; then
echo "### Latest Throughput Report" >> "$REPORT_FILE"
echo "\`\`\`json" >> "$REPORT_FILE"
cat "$LATEST_THROUGHPUT" >> "$REPORT_FILE"
echo "\`\`\`" >> "$REPORT_FILE"
fi
# Add recommendations
cat >> "$REPORT_FILE" << EOF
## Recommendations
Based on the benchmark results, consider the following optimizations:
1. **Gas Optimization**: Review high-gas functions for optimization opportunities
2. **Execution Time**: Identify bottlenecks in complex contract operations
3. **Throughput**: Consider batching operations for improved throughput
## Historical Trends
Compare with previous reports to identify performance trends.
---
*Report generated by AITBC benchmarking system*
EOF
echo "✅ Benchmark report generated: $REPORT_FILE"