summaryrefslogtreecommitdiffstats
path: root/profile.c
diff options
context:
space:
mode:
authorGravatar Anton Lundin <glance@acc.umu.se>2014-06-29 20:23:00 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-06-29 17:16:43 -0700
commit537beb319be5eff3f522766afa3f31404e692288 (patch)
treefda76f3cfca95c3d3cc3aec1d2cdb074d17827bb /profile.c
parentb2288e1e3d231ed9d5629942730d49cb7ffec96b (diff)
downloadsubsurface-537beb319be5eff3f522766afa3f31404e692288.tar.gz
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 <glance@acc.umu.se> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'profile.c')
-rw-r--r--profile.c12
1 files changed, 12 insertions, 0 deletions
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);