feat: add performance benchmark script
This commit is contained in:
+38
-18
@@ -182,9 +182,6 @@ Toutes ces sources sont modifiables dans `includes/config.local.php` (voir <<fr-
|
||||
│ ├── sidebar.php # Navigation latérale
|
||||
│ ├── mobile-menu.php # Menu mobile coulissant
|
||||
│ ├── hero-section.php # Bannière d'accueil (live/vidéo/playlist)
|
||||
│ ├── featured-videos.php # ⚠️ legacy, non utilisé par les pages actuelles
|
||||
│ ├── recent-videos.php # ⚠️ legacy, non utilisé par les pages actuelles
|
||||
│ ├── pwa-init.php # ⚠️ legacy, PWA désormais inline dans index.php
|
||||
│ └── lib/
|
||||
│ └── markdown.php # Rendu Markdown (sous-ensemble PeerTube)
|
||||
├── js/
|
||||
@@ -197,6 +194,7 @@ Toutes ces sources sont modifiables dans `includes/config.local.php` (voir <<fr-
|
||||
│ ├── pleroma-adapter.js # Adaptateur Pleroma → API Mastodon
|
||||
│ └── pwa-update.js # Enregistrement SW + modal de mise à jour
|
||||
├── scripts/
|
||||
│ ├── benchmark.php # Benchmark TTFB froid/chaud des pages clés
|
||||
│ ├── check.sh # Vérifications qualité en local (avant push)
|
||||
│ └── warm-cache.php # Préchauffage du cache API (cron)
|
||||
├── uploads/ # Images d'annonces (non versionné, hors .gitkeep)
|
||||
@@ -633,10 +631,6 @@ TIP: Si vous déployez une instance indépendante, remplacez `LIBERAPAY_URL` par
|
||||
|===
|
||||
| Constante | Défaut | Description
|
||||
|
||||
| `TAG_INDEPENDENCE`
|
||||
| `'indépendance'`
|
||||
| Tag de la fonction `getIndependenceVideos()` (pas de section d'accueil associée actuellement)
|
||||
|
||||
| `SHORTS_MAX_DURATION`
|
||||
| `180`
|
||||
| Durée max d'un short (s) ; ratio portrait (`aspectRatio ≤ 1`) aussi requis
|
||||
@@ -675,9 +669,9 @@ TIP: Si vous déployez une instance indépendante, remplacez `LIBERAPAY_URL` par
|
||||
| `6`
|
||||
| Vidéos chargées par clic sur « Voir plus »
|
||||
|
||||
| `FEATURED_VIDEOS_COUNT` / `INDEPENDENCE_VIDEOS_COUNT`
|
||||
| `FEATURED_VIDEOS_COUNT`
|
||||
| `6`
|
||||
| Réservés (sections non affichées actuellement)
|
||||
| Réservé (section non affichée actuellement)
|
||||
|===
|
||||
|
||||
.Cache
|
||||
@@ -970,6 +964,22 @@ python3 -m venv /tmp/test-venv
|
||||
|
||||
NOTE: Les tests E2E démarrent un serveur PHP local (`php -S`) et s'appuient sur la configuration par défaut. Les appels réseau vers PeerTube sont sautés proprement si l'instance est injoignable.
|
||||
|
||||
==== ⏱️ Benchmark de performance
|
||||
|
||||
Le script `scripts/benchmark.php` mesure le TTFB (_time to first byte_) des pages clés — accueil (`/`), page vidéo (`/video.php?id=…`) et page catégorie (`/categories.php?id=…`) — dans deux conditions :
|
||||
|
||||
- *à froid* : cache API vidé (le premier visiteur paie le coût des appels API externes) ;
|
||||
- *à chaud* : cache API rempli (moyenne sur 3 requêtes).
|
||||
|
||||
Il démarre un serveur PHP local (`php -S`), découvre automatiquement une vidéo et une catégorie réelles via l'API PeerTube (les pages correspondantes sont ignorées si l'instance est injoignable) et affiche la taille du cache API avant et après les mesures.
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
php scripts/benchmark.php
|
||||
----
|
||||
|
||||
NOTE: Le script vide le cache API (`cache/api`) : à utiliser hors production, ou suivi d'un préchauffage (`scripts/warm-cache.php`).
|
||||
|
||||
=== 📜 Licence
|
||||
|
||||
Copyright (C) 2025 Cédric Famibelle-Pronzola & *ORGANISATION KA INTERNATIONALE*
|
||||
@@ -1155,9 +1165,6 @@ All of these sources can be changed in `includes/config.local.php` (see <<en-con
|
||||
│ ├── sidebar.php # Side navigation
|
||||
│ ├── mobile-menu.php # Slide-in mobile menu
|
||||
│ ├── hero-section.php # Homepage banner (live/video/playlist)
|
||||
│ ├── featured-videos.php # ⚠️ legacy, unused by current pages
|
||||
│ ├── recent-videos.php # ⚠️ legacy, unused by current pages
|
||||
│ ├── pwa-init.php # ⚠️ legacy, PWA now inlined in index.php
|
||||
│ └── lib/
|
||||
│ └── markdown.php # Markdown renderer (PeerTube-flavored subset)
|
||||
├── js/
|
||||
@@ -1170,6 +1177,7 @@ All of these sources can be changed in `includes/config.local.php` (see <<en-con
|
||||
│ ├── pleroma-adapter.js # Pleroma → Mastodon API adapter
|
||||
│ └── pwa-update.js # SW registration + update modal
|
||||
├── scripts/
|
||||
│ ├── benchmark.php # Cold/warm TTFB benchmark of key pages
|
||||
│ ├── check.sh # Local quality checks (before pushing)
|
||||
│ └── warm-cache.php # API cache warm-up (cron)
|
||||
├── uploads/ # Announcement images (not versioned, except .gitkeep)
|
||||
@@ -1606,10 +1614,6 @@ TIP: If you deploy an independent instance, replace `LIBERAPAY_URL` with your ow
|
||||
|===
|
||||
| Constant | Default | Description
|
||||
|
||||
| `TAG_INDEPENDENCE`
|
||||
| `'indépendance'`
|
||||
| Tag used by `getIndependenceVideos()` (no associated homepage section currently)
|
||||
|
||||
| `SHORTS_MAX_DURATION`
|
||||
| `180`
|
||||
| Max short duration (s); portrait ratio (`aspectRatio ≤ 1`) also required
|
||||
@@ -1648,9 +1652,9 @@ TIP: If you deploy an independent instance, replace `LIBERAPAY_URL` with your ow
|
||||
| `6`
|
||||
| Videos loaded per "Load more" click
|
||||
|
||||
| `FEATURED_VIDEOS_COUNT` / `INDEPENDENCE_VIDEOS_COUNT`
|
||||
| `FEATURED_VIDEOS_COUNT`
|
||||
| `6`
|
||||
| Reserved (sections not currently displayed)
|
||||
| Reserved (section not currently displayed)
|
||||
|===
|
||||
|
||||
.Cache
|
||||
@@ -1943,6 +1947,22 @@ python3 -m venv /tmp/test-venv
|
||||
|
||||
NOTE: E2E tests start a local PHP server (`php -S`) and rely on the default configuration. Network calls to PeerTube are skipped gracefully if the instance is unreachable.
|
||||
|
||||
==== ⏱️ Performance benchmark
|
||||
|
||||
The `scripts/benchmark.php` script measures the TTFB (_time to first byte_) of key pages — homepage (`/`), video page (`/video.php?id=…`) and category page (`/categories.php?id=…`) — under two conditions:
|
||||
|
||||
- *cold*: API cache emptied (the first visitor pays the cost of external API calls);
|
||||
- *warm*: API cache filled (average over 3 requests).
|
||||
|
||||
It starts a local PHP server (`php -S`), automatically discovers a real video and category through the PeerTube API (the corresponding pages are skipped if the instance is unreachable) and reports the API cache size before and after the measurements.
|
||||
|
||||
[source,bash]
|
||||
----
|
||||
php scripts/benchmark.php
|
||||
----
|
||||
|
||||
NOTE: The script purges the API cache (`cache/api`): use it outside production, or follow it with a cache warmup (`scripts/warm-cache.php`).
|
||||
|
||||
=== 📜 License
|
||||
|
||||
Copyright (C) 2025 Cédric Famibelle-Pronzola & *ORGANISATION KA INTERNATIONALE*
|
||||
|
||||
Reference in New Issue
Block a user