Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MAINTENANCE] Ajout de l'évaluation de performance des routes dans GeoNature #2896

Merged
merged 27 commits into from
Mar 27, 2024

Conversation

jacquesfize
Copy link
Contributor

@jacquesfize jacquesfize commented Feb 6, 2024

This PR includes perfomance evaluation of specific routes in GeoNature backend. We use pytest-benchmark module to compute and store execution time of a designated python function. To automate the generation of pytest function to run a benchmark on a route, we designed a class name BenchmarkTest.

TODO LIST:

  • Complete the declaration of benchmarked routes
  • Build a PostgreSQL dump of an instance of GeoNature with a large amount of data
  • Find a way to store and reuse execution time for comparison in a CI
  • Compare results from different runs on the same commit

Flask routes included in the benchmark

Module Route
Metadata gn_meta.get_acquisition_frameworks_list
Metadata gn_meta.get_datasets
OccHab occhab.get_station
OccHab occhab.list_stations (with or without restricted permissions)
OccHab occhab.export_all_habitats (with or without restricted permissions)
Occtax pr_occtax.getReleves
Synthese gn_synthese.getDefaultsNomenclatures
Synthese gn_synthese.get_observations_for_web (polygon, bbox, taxon_tree, departement, region, city) (with/without blurring)
Synthese gn_synthese.export_observations_web (10^3,10^4,10^5,10^6 obs.) (with/without blurring)
Synthese gn_synthese.export_status (10^3,10^4,10^5,10^6 obs.) (with/without blurring)
Synthese gn_synthese.export_taxon_web (10^3,10^4,10^5,10^6 obs.) (with/without blurring)

First results

Synthese routes results

Capture d’écran du 2024-03-05 16-27-12

Occhab routes resuts

Capture d’écran du 2024-03-05 17-18-45

Occtax routes results

Capture d’écran du 2024-03-05 17-20-18

How to compare with previous benchmark

pytest --benchmark-only --benchmark-compare-fail="mean:0.00001" --benchmark-compare=<fichier_vieux_benchmark.json>
  • --benchmark-compare-fail allows to indicate the condition of non-failure
  • --benchmark-compare is the JSON files storing the last stable performances

To store the JSON containing the last accepted performance, we can use dedicated online storage like http://geonature.fr/data.

Copy link

codecov bot commented Feb 7, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.53%. Comparing base (2a0582d) to head (f5d7190).

❗ Current head f5d7190 differs from pull request most recent head e77cd83. Consider uploading reports for the commit e77cd83 to get more accurate results

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #2896   +/-   ##
========================================
  Coverage    78.53%   78.53%           
========================================
  Files           89       89           
  Lines         7236     7236           
========================================
  Hits          5683     5683           
  Misses        1553     1553           
Flag Coverage Δ
pytest 78.53% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@jacquesfize jacquesfize force-pushed the feat/eval-perf branch 2 times, most recently from 817ed04 to d6802b4 Compare February 21, 2024 13:52
@jacquesfize jacquesfize added backend backend-test Ajout/Modification de test pour le backend labels Mar 8, 2024
@jacquesfize jacquesfize changed the title Ajout de l'évaluation de performance des routes dans GeoNature [MAINTENANCE] Ajout de l'évaluation de performance des routes dans GeoNature Mar 14, 2024
@VincentCauchois VincentCauchois self-assigned this Mar 26, 2024
@VincentCauchois VincentCauchois added this to the 2.14.1 milestone Mar 26, 2024
@VincentCauchois VincentCauchois added performance python Pull requests that update Python code labels Mar 26, 2024
@jacquesfize jacquesfize force-pushed the feat/eval-perf branch 2 times, most recently from 265ab0d to f5d7190 Compare March 27, 2024 13:25
@jacquesfize jacquesfize merged commit 55be4d8 into develop Mar 27, 2024
7 checks passed
@jacquesfize jacquesfize deleted the feat/eval-perf branch March 27, 2024 13:55
@jacquesfize jacquesfize mentioned this pull request Apr 18, 2024
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend backend-test Ajout/Modification de test pour le backend performance python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants