benchmark.yml 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. name: Benchmark
  2. on:
  3. push:
  4. branches:
  5. - ci
  6. schedule:
  7. - cron: '0 */12 * * *'
  8. jobs:
  9. test:
  10. runs-on: ubuntu-latest
  11. services:
  12. redis:
  13. image: redis
  14. ports:
  15. - 6379:6379
  16. postgres:
  17. image: postgres:9.6
  18. ports:
  19. - 5432:5432
  20. env:
  21. POSTGRES_USER: peertube
  22. POSTGRES_HOST_AUTH_METHOD: trust
  23. env:
  24. PGUSER: peertube
  25. PGHOST: localhost
  26. steps:
  27. - uses: actions/checkout@v3
  28. - uses: './.github/actions/reusable-prepare-peertube-build'
  29. with:
  30. node-version: '16.x'
  31. - uses: './.github/actions/reusable-prepare-peertube-run'
  32. - name: Build
  33. run: |
  34. startClient=`date +%s`
  35. npm run build:client
  36. endClient=`date +%s`
  37. clientBuildTime=$((endClient-startClient))
  38. startServer=`date +%s`
  39. npm run build:server
  40. endServer=`date +%s`
  41. serverBuildTime=$((endServer-startServer))
  42. echo '{"clientBuildTime":'$clientBuildTime',"serverBuildTime":'$serverBuildTime'}'> build-time.json
  43. - name: Startup
  44. run: |
  45. npm run clean:server:test
  46. startCold=`date +%s%3N`
  47. NODE_APP_INSTANCE=1 NODE_ENV=test node dist/server --benchmark-startup
  48. endCold=`date +%s%3N`
  49. coldStartupTime=$(echo "scale=2; ($endCold-$startCold)/1000" | bc)
  50. startHot=`date +%s%3N`
  51. NODE_APP_INSTANCE=1 NODE_ENV=test node dist/server --benchmark-startup
  52. endHot=`date +%s%3N`
  53. hotStartupTime=$(echo "scale=2; ($endHot-$startHot)/1000" | bc)
  54. echo '{"coldStartupTime":'$coldStartupTime',"hotStartupTime":'$hotStartupTime'}'> startup-time.json
  55. - name: Run benchmark
  56. run: |
  57. npm run benchmark-server -- -o benchmark.json
  58. - name: Display result
  59. run: |
  60. cat benchmark.json build-time.json startup-time.json
  61. - name: Upload benchmark result
  62. uses: './.github/actions/reusable-deploy'
  63. with:
  64. source: benchmark.json build-time.json startup-time.json
  65. destination: peertube-stats
  66. knownHosts: ${{ secrets.STATS_DEPLOYEMENT_KNOWN_HOSTS }}
  67. deployKey: ${{ secrets.STATS_DEPLOYEMENT_KEY }}
  68. deployUser: ${{ secrets.STATS_DEPLOYEMENT_USER }}
  69. deployHost: ${{ secrets.STATS_DEPLOYEMENT_HOST }}