@sdeverywhere/check-core 0.1.10 → 0.1.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +63 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +64 -5
- package/dist/index.d.ts +64 -5
- package/dist/index.js +63 -15
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -3811,7 +3811,7 @@ function resolveScenarioForInputSpecs(modelInputsL, modelInputsR, key, id, title
|
|
|
3811
3811
|
};
|
|
3812
3812
|
}
|
|
3813
3813
|
function resolveScenarioForDistinctInputSpecs(modelInputsL, modelInputsR, key, id, title, subtitle, inputSpecsL, inputSpecsR) {
|
|
3814
|
-
const
|
|
3814
|
+
const inputsWithIssues = [];
|
|
3815
3815
|
const settingsL = [];
|
|
3816
3816
|
const settingsR = [];
|
|
3817
3817
|
function resolveInputSpec(side, modelInputs, inputSpec) {
|
|
@@ -3826,13 +3826,14 @@ function resolveScenarioForDistinctInputSpecs(modelInputsL, modelInputsR, key, i
|
|
|
3826
3826
|
default:
|
|
3827
3827
|
(0, import_assert_never10.assertNever)(inputSpec);
|
|
3828
3828
|
}
|
|
3829
|
-
if (inputState.error !== void 0) {
|
|
3830
|
-
|
|
3829
|
+
if (inputState.error !== void 0 || inputState.warning !== void 0) {
|
|
3830
|
+
inputsWithIssues.push({
|
|
3831
3831
|
requestedName: inputSpec.inputName,
|
|
3832
3832
|
stateL: side === "left" ? inputState : {},
|
|
3833
3833
|
stateR: side === "right" ? inputState : {}
|
|
3834
3834
|
});
|
|
3835
|
-
}
|
|
3835
|
+
}
|
|
3836
|
+
if (inputState.error === void 0 && inputState.inputVar !== void 0) {
|
|
3836
3837
|
const inputSetting = inputSettingFromResolvedInputState(inputState);
|
|
3837
3838
|
if (side === "left") {
|
|
3838
3839
|
settingsL.push(inputSetting);
|
|
@@ -3843,9 +3844,12 @@ function resolveScenarioForDistinctInputSpecs(modelInputsL, modelInputsR, key, i
|
|
|
3843
3844
|
}
|
|
3844
3845
|
inputSpecsL.forEach((inputSpec) => resolveInputSpec("left", modelInputsL, inputSpec));
|
|
3845
3846
|
inputSpecsR.forEach((inputSpec) => resolveInputSpec("right", modelInputsR, inputSpec));
|
|
3847
|
+
const hasFatalError = inputsWithIssues.some(
|
|
3848
|
+
(input) => input.stateL.error !== void 0 || input.stateR.error !== void 0
|
|
3849
|
+
);
|
|
3846
3850
|
let specL;
|
|
3847
3851
|
let specR;
|
|
3848
|
-
if (
|
|
3852
|
+
if (!hasFatalError) {
|
|
3849
3853
|
specL = inputSettingsSpec(settingsL);
|
|
3850
3854
|
specR = inputSettingsSpec(settingsR);
|
|
3851
3855
|
}
|
|
@@ -3857,7 +3861,7 @@ function resolveScenarioForDistinctInputSpecs(modelInputsL, modelInputsR, key, i
|
|
|
3857
3861
|
subtitle,
|
|
3858
3862
|
settings: {
|
|
3859
3863
|
kind: "input-settings",
|
|
3860
|
-
inputs:
|
|
3864
|
+
inputs: inputsWithIssues
|
|
3861
3865
|
},
|
|
3862
3866
|
specL,
|
|
3863
3867
|
specR
|
|
@@ -4024,8 +4028,10 @@ function resolveInputVarAtValue(inputVar, value) {
|
|
|
4024
4028
|
};
|
|
4025
4029
|
} else {
|
|
4026
4030
|
return {
|
|
4027
|
-
|
|
4028
|
-
|
|
4031
|
+
inputVar,
|
|
4032
|
+
value,
|
|
4033
|
+
warning: {
|
|
4034
|
+
kind: "value-out-of-range"
|
|
4029
4035
|
}
|
|
4030
4036
|
};
|
|
4031
4037
|
}
|
|
@@ -4631,34 +4637,76 @@ function handleRenames(origCurrentBundle, renamedDatasetKeys) {
|
|
|
4631
4637
|
var import_assert_never11 = require("assert-never");
|
|
4632
4638
|
|
|
4633
4639
|
// src/perf/perf-stats.ts
|
|
4640
|
+
function percentile(sorted, p) {
|
|
4641
|
+
if (sorted.length === 1) {
|
|
4642
|
+
return sorted[0];
|
|
4643
|
+
}
|
|
4644
|
+
const rank = p * (sorted.length - 1);
|
|
4645
|
+
const lo = Math.floor(rank);
|
|
4646
|
+
const hi = Math.ceil(rank);
|
|
4647
|
+
if (lo === hi) {
|
|
4648
|
+
return sorted[lo];
|
|
4649
|
+
}
|
|
4650
|
+
const frac = rank - lo;
|
|
4651
|
+
return sorted[lo] + (sorted[hi] - sorted[lo]) * frac;
|
|
4652
|
+
}
|
|
4634
4653
|
var PerfStats = class {
|
|
4635
4654
|
constructor() {
|
|
4636
4655
|
this.times = [];
|
|
4637
4656
|
}
|
|
4657
|
+
/**
|
|
4658
|
+
* Record a single run time sample.
|
|
4659
|
+
*
|
|
4660
|
+
* @param timeInMillis The run time in milliseconds.
|
|
4661
|
+
*/
|
|
4638
4662
|
addRun(timeInMillis) {
|
|
4639
4663
|
this.times.push(timeInMillis);
|
|
4640
4664
|
}
|
|
4665
|
+
/**
|
|
4666
|
+
* Get the raw run time samples that have been recorded.
|
|
4667
|
+
*
|
|
4668
|
+
* @returns A copy of the recorded run times, in insertion order.
|
|
4669
|
+
*/
|
|
4670
|
+
getTimes() {
|
|
4671
|
+
return this.times.slice();
|
|
4672
|
+
}
|
|
4673
|
+
/**
|
|
4674
|
+
* Produce a `PerfReport` summarizing the recorded samples.
|
|
4675
|
+
*
|
|
4676
|
+
* @returns The summary report.
|
|
4677
|
+
*/
|
|
4641
4678
|
toReport() {
|
|
4642
4679
|
if (this.times.length === 0) {
|
|
4643
4680
|
return {
|
|
4644
4681
|
minTime: 0,
|
|
4645
4682
|
maxTime: 0,
|
|
4646
4683
|
avgTime: 0,
|
|
4684
|
+
medianTime: 0,
|
|
4685
|
+
p95Time: 0,
|
|
4686
|
+
stdDev: 0,
|
|
4647
4687
|
allTimes: []
|
|
4648
4688
|
};
|
|
4649
4689
|
}
|
|
4650
|
-
const
|
|
4651
|
-
const
|
|
4652
|
-
const
|
|
4653
|
-
const
|
|
4654
|
-
const
|
|
4690
|
+
const sortedTimes = this.times.slice().sort((a, b) => a - b);
|
|
4691
|
+
const n = sortedTimes.length;
|
|
4692
|
+
const minTime = sortedTimes[0];
|
|
4693
|
+
const maxTime = sortedTimes[n - 1];
|
|
4694
|
+
const minIndex = Math.floor(n / 4);
|
|
4695
|
+
const maxIndex = minIndex + Math.max(1, Math.ceil(n / 2));
|
|
4655
4696
|
const middleTimes = sortedTimes.slice(minIndex, maxIndex);
|
|
4656
|
-
const
|
|
4657
|
-
const
|
|
4697
|
+
const avgTime = middleTimes.reduce((a, b) => a + b, 0) / middleTimes.length;
|
|
4698
|
+
const medianTime = percentile(sortedTimes, 0.5);
|
|
4699
|
+
const p95Time = percentile(sortedTimes, 0.95);
|
|
4700
|
+
const mean = sortedTimes.reduce((a, b) => a + b, 0) / n;
|
|
4701
|
+
const variance = sortedTimes.reduce((acc, t) => acc + (t - mean) * (t - mean), 0) / n;
|
|
4702
|
+
const stdDev = Math.sqrt(variance);
|
|
4658
4703
|
return {
|
|
4659
4704
|
minTime,
|
|
4660
4705
|
maxTime,
|
|
4661
4706
|
avgTime,
|
|
4707
|
+
medianTime,
|
|
4708
|
+
p95Time,
|
|
4709
|
+
stdDev,
|
|
4662
4710
|
allTimes: sortedTimes
|
|
4663
4711
|
};
|
|
4664
4712
|
}
|