Skip to content

Commit

Permalink
Marked issues with collecting profile statistics
Browse files Browse the repository at this point in the history
  • Loading branch information
jirkapok committed Jan 15, 2025
1 parent 3c13f7e commit 8bf11e4
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion projects/scuba-physics/src/lib/AlgorithmContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,13 @@ export class AlgorithmContext {
return newGas;
}

// TODO split methods with/without collecting statistics (ceilings, tissues, overPressures)
public addSaturation(currentDepth: number): void {
if (!FeatureFlags.Instance.collectSaturation) {
this.tissuesHistory.push(this.tissues.finalState());
return;
}

this.tissuesHistory.push(this.tissues.finalState());
const ambientPressure = this.depthConverter.toBar(currentDepth);
const currentOverPressures = this.tissues.saturationRatio(ambientPressure, this.depthConverter.surfacePressure, 1);
this.tissueOverPressures.push(currentOverPressures);
Expand Down
1 change: 1 addition & 0 deletions projects/scuba-physics/src/lib/ProfileTissues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export class ProfileTissues {
return surfaceGradient;
}

// TODO replace TissueOverPressures with LoadedTissue, since we cant use speed to determine offgasing
/**
* Finds the first moment, where the 5th tissue starts off gasing.
* Throws Error in case any sample has wrong number of tissues.
Expand Down
2 changes: 1 addition & 1 deletion projects/scuba-physics/src/lib/Tissues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ export class Tissues {
}).value();
}

// TODO Define type for Tissue saturion snapshot and move doc to algorithm CalculatedProfile
// TODO Define type for Tissue saturation snapshot and move doc to algorithm CalculatedProfile
// TODO verify the doc and meaning of the values
/**
* Calculates saturation ratio for all tissues as percents relative to ambient pressure.
Expand Down
21 changes: 15 additions & 6 deletions projects/scuba-physics/src/lib/performanceTests.spec.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'lodash';
import { Time } from './Time';
import { AlgorithmParams, BuhlmannAlgorithm } from './BuhlmannAlgorithm';
import { Gas, Gases } from './Gases';
Expand All @@ -24,13 +25,21 @@ describe('Performance', () => {
});

const assertDuration = (message: string, limit: number, actionToMeasure: () => void): void => {
const startTime = performance.now();
actionToMeasure();
const endTime = performance.now();
const iterations = 1;
const results: number[] = [];

const methodDuration = Precision.round(endTime - startTime);
console.log(`${message}: ${methodDuration} ms (max ${limit} ms)`);
expect(methodDuration).toBeLessThan(limit);
for (let i = 0; i < iterations; i++) {
const startTime = performance.now();
actionToMeasure();
const endTime = performance.now();

const methodDuration = Precision.round(endTime - startTime);
results.push(methodDuration);
}

const averageDuration = _(results).mean();
console.log(`${message}: ${averageDuration} ms (max ${limit} ms)`);
expect(averageDuration).toBeLessThan(limit);
};

it('Decompression is calculated within 100 ms', () => {
Expand Down

0 comments on commit 8bf11e4

Please sign in to comment.