"Quick" versions of TTS calculations
Anton Lundin
glance at acc.umu.se
Wed Jun 11 12:06:00 PDT 2014
Hi.
After "Force TTS/NDL calculation off if things take too long" i kinda
grew tired of always re-enabling the TTS/NDL button, so i thought about
it a bit.
Attached is a one patch that uses the TTS from the previous data point
if the stopdepth and stoptime calculated are the same. This shows me a
speedup of about 4 times on some of my longer dives.
Attached is also another variant that doesn't calculate NDL/TTS on every
sample, but only every 60 seconds. I run my OSTC3 with 2s sample
interval so thats also quite a speedup.
I can see us applying any of these two techniques, as long as we stop
disabling TTS/NDL when i would like to look at the numbers from my
dives.
//Anton
--
Anton Lundin +46702-161604
-------------- next part --------------
diff --git i/profile.c w/profile.c
index b40ef62..19bc03e 100644
--- i/profile.c
+++ w/profile.c
@@ -1070,6 +1070,15 @@ static void calculate_ndl_tts(double tissue_tolerance, struct plot_data *entry,
&dive->cylinder[cylinderindex].gasmix, time_stepsize, entry->po2 * 1000, dive);
if (deco_allowed_depth(tissue_tolerance, surface_pressure, dive, 1) <= next_stop) {
+ /* if we have the same stopdepth and stoptime as the previous datapoint
+ * just reuse that tts and bail here
+ */
+ struct plot_data *prev_entry = (entry - 1);
+ if (prev_entry->stopdepth_calc == entry->stopdepth_calc && prev_entry->stoptime_calc == entry->stoptime_calc) {
+ entry->tts_calc = prev_entry->tts_calc;
+ break;
+ }
+
/* move to the next stop and add the travel between stops */
for (; ascent_depth > next_stop; ascent_depth -= ascent_mm_per_deco_step, entry->tts_calc += ascent_s_per_deco_step)
add_segment(depth_to_mbar(ascent_depth, dive) / 1000.0,
-------------- next part --------------
diff --git i/profile.c w/profile.c
index b40ef62..5c36672 100644
--- i/profile.c
+++ w/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 60 seconds */
+ if ((entry->sec - last_ndl_tts_calc_time) < 60) {
+ 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);
More information about the subsurface
mailing list