From 537beb319be5eff3f522766afa3f31404e692288 Mon Sep 17 00:00:00 2001 From: Anton Lundin Date: Sun, 29 Jun 2014 20:23:00 +0200 Subject: Only calculate deco stops, TTS and NDL every 30s This introduces a limiter that we only calculate deco stop, TTS and NDL with a minimum of 30s intervall and just reused the values from the previous sample in other cases. I run my OSTC3 at 2s sample intervall so this is a 15x speedup in that case. Signed-off-by: Anton Lundin Signed-off-by: Dirk Hohndel --- profile.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/profile.c b/profile.c index a0bde3cfd..1af7249ee 100644 --- a/profile.c +++ b/profile.c @@ -1088,6 +1088,7 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru int i; double surface_pressure = (dc->surface_pressure.mbar ? dc->surface_pressure.mbar : get_surface_pressure_in_mbar(dive, true)) / 1000.0; double tissue_tolerance = 0; + int last_ndl_tts_calc_time = 0; for (i = 1; i < pi->nr; i++) { struct plot_data *entry = pi->entry + i; int j, t0 = (entry - 1)->sec, t1 = entry->sec; @@ -1112,6 +1113,17 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru /* should we do more calculations? * We don't for print-mode because this info doesn't show up there */ if (prefs.calcndltts && !print_mode) { + /* only calculate ndl/tts on every 30 seconds */ + if ((entry->sec - last_ndl_tts_calc_time) < 30) { + struct plot_data *prev_entry = (entry - 1); + entry->stoptime_calc = prev_entry->stoptime_calc; + entry->stopdepth_calc = prev_entry->stopdepth_calc; + entry->tts_calc = prev_entry->tts_calc; + entry->ndl_calc = prev_entry->ndl_calc; + continue; + } + last_ndl_tts_calc_time = entry->sec; + /* We are going to mess up deco state, so store it for later restore */ char *cache_data = NULL; cache_deco_state(tissue_tolerance, &cache_data); -- cgit v1.2.3-70-g09d2