Skip to content

Commit 3193703

Browse files
authored
Merge pull request #8993 from michtesar/8970-bench-text-to-model
Add typography to model performance tests
2 parents 4c0f36f + 5d02081 commit 3193703

1 file changed

Lines changed: 50 additions & 0 deletions

File tree

‎test/bench/typography.bench.js‎

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ const TO_POINTS_CASES = [
2323
{label: "textToPoints() paragraph", str: strs.paragraph, textSize: 20, sampleFactor: 0.5, points: 21275, variance: 50, render: false},
2424
];
2525

26+
const TO_MODEL_CASES = [
27+
{label: "textToModel() single word", str: strs.single, textSize: 20, sampleFactor: 0.5, render: false},
28+
{label: "textToModel() single word, 150pt", str: strs.single, textSize: 150, sampleFactor: 0.5, render: false},
29+
{label: "textToModel() single word, with render", str: strs.single, textSize: 20, sampleFactor: 0.5, render: true},
30+
{label: "textToModel() 10 words", str: strs.ten, textSize: 20, sampleFactor: 0.5, render: false},
31+
{label: "textToModel() paragraph", str: strs.paragraph, textSize: 20, sampleFactor: 0.5, render: false},
32+
];
33+
2634
async function bootstrap(w = 400, h = 400, renderer = undefined) {
2735
var myp5;
2836
var font;
@@ -102,6 +110,27 @@ describe("Typography: bench WebGL", function() {
102110
);
103111
}
104112

113+
for (let testCase of TO_MODEL_CASES) {
114+
bench(
115+
testCase.label,
116+
async () => {
117+
const model = font.textToModel(testCase.str, 10, 20, { sampleFactor: testCase.sampleFactor });
118+
assert.isAbove(model.vertices.length, 0);
119+
if (testCase.render) {
120+
myp5.model(model);
121+
}
122+
},
123+
{
124+
...options,
125+
setup: async () => {
126+
({myp5, font} = await bootstrap(400, 400, WEBGL));
127+
myp5.textSize(testCase.textSize);
128+
},
129+
teardown: () => myp5.remove()
130+
}
131+
);
132+
}
133+
105134
});
106135

107136
describe("Typography: bench WebGPU", function() {
@@ -129,4 +158,25 @@ describe("Typography: bench WebGPU", function() {
129158
);
130159
}
131160

161+
for (let testCase of TO_MODEL_CASES) {
162+
bench(
163+
testCase.label,
164+
async () => {
165+
const model = font.textToModel(testCase.str, 10, 20, { sampleFactor: testCase.sampleFactor });
166+
assert.isAbove(model.vertices.length, 0);
167+
if (testCase.render) {
168+
myp5.model(model);
169+
}
170+
},
171+
{
172+
...options,
173+
setup: async () => {
174+
({myp5, font} = await bootstrap(400, 400, WEBGPU));
175+
myp5.textSize(testCase.textSize);
176+
},
177+
teardown: () => myp5.remove()
178+
}
179+
);
180+
}
181+
132182
});

0 commit comments

Comments
 (0)