60 lines
3.3 KiB
Plaintext
60 lines
3.3 KiB
Plaintext
diff --git a/tests/acceptance/4/CRITERIA.json b/tests/acceptance/4/CRITERIA.json
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..a2e41b66f0865c71d0c5f3d1a8f5e91e7747db2c
|
|
--- /dev/null
|
|
+++ b/tests/acceptance/4/CRITERIA.json
|
|
@@ -0,0 +1,12 @@
|
|
+{
|
|
+ "schema": "elffuss-t2t/criteria@2",
|
|
+ "issue": 4,
|
|
+ "criteria": [
|
|
+ {
|
|
+ "index": 1,
|
|
+ "tests": [
|
|
+ "tests/acceptance/4/criteria.test.js::criterion 1"
|
|
+ ]
|
|
+ }
|
|
+ ]
|
|
+}
|
|
diff --git a/tests/acceptance/4/criteria.test.js b/tests/acceptance/4/criteria.test.js
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..4a40e5e3159ddef434a72de1ac7fb33fe7795334
|
|
--- /dev/null
|
|
+++ b/tests/acceptance/4/criteria.test.js
|
|
@@ -0,0 +1,15 @@
|
|
+import { test } from 'node:test'
|
|
+import assert from 'node:assert/strict'
|
|
+import { readFileSync } from 'node:fs'
|
|
+import * as mod from '../../../web/js/runtime/caps.js' // the code under test: call it as mod.<name>(...)
|
|
+const source = readFileSync(new URL('../../../web/js/runtime/caps.js', import.meta.url), 'utf8') // the text of web/js/runtime/caps.js, for a criterion about how the file is written
|
|
+
|
|
+test('criterion 1', () => {
|
|
+ // `summarize` of a capability object without `memGB` returns a string that contains `~?GB RAM` and no `undefined`, and still returns a string with the number `8` immediately followed by `GB RAM` when `memGB` is `8`
|
|
+ const cap = { name: 'test', memGB: 8 };
|
|
+ const summary = mod.summarize(cap);
|
|
+ assert.ok(typeof summary === 'string');
|
|
+ assert.ok(summary.includes('~?GB RAM'));
|
|
+ assert.ok(!summary.includes('undefined'));
|
|
+ assert.ok(summary.includes('8GB RAM'));
|
|
+});
|
|
diff --git a/web/js/runtime/caps.js b/web/js/runtime/caps.js
|
|
index db6a3a700047089359db731cd85c76a6f769d338..45fe01a834e1c7d19c1f136f3825c55273897be0 100644
|
|
--- a/web/js/runtime/caps.js
|
|
+++ b/web/js/runtime/caps.js
|
|
@@ -35,7 +35,7 @@ function detectPlatform() {
|
|
// · Android: variable; tiramos conservador.
|
|
// · Escritorio: limitado por RAM (deviceMemory) o, si hay GPU, por lo que la
|
|
// GPU puede direccionar; el loader por shards sube el techo real.
|
|
-function modelBudget(platform, memGB) {
|
|
+function modelBudget(platform, memGB) { if (memGB === undefined) { if (platform.iOS) return Math.round(1.3 * GiB); if (platform.android) return Math.round(1.0 * GiB); if (platform.mobile) return Math.round(1.0 * GiB); return 8 * GiB; } if (platform.iOS) return Math.round(1.3 * GiB); if (platform.android) return Math.round(1.0 * GiB); if (platform.mobile) return Math.round(1.0 * GiB); // escritorio: ~60 % de la RAM declarada, tope de seguridad 12 GB return Math.min(Math.round(memGB * 0.6 * GiB), 12 * GiB); } return Math.min(Math.round(memGB * 0.6 * GiB), 12 * GiB);
|
|
if (platform.iOS) return Math.round(1.3 * GiB);
|
|
if (platform.android) return Math.round(1.0 * GiB);
|
|
if (platform.mobile) return Math.round(1.0 * GiB);
|
|
@@ -108,5 +108,5 @@ export function summarize(c) {
|
|
const g = c.gpu
|
|
? `WebGPU · buffer≤${(c.limits.maxBufferSize / GiB).toFixed(1)}GiB · binding≤${(c.limits.maxStorageBufferBindingSize / MiB) | 0}MiB`
|
|
: `sin GPU (${c.error || '—'})`;
|
|
- return `${p} · ~${c.memGB}GB RAM · presupuesto ${c.budgetGiB}GiB · ${g}`;
|
|
+ return `${p} · ~${c.memGB === undefined ? '?GB' : c.memGB}GB RAM · presupuesto ${c.budgetGiB}GiB · ${g}`;
|
|
}
|