diff --git a/module/classes/DevModeConfig.mjs b/module/classes/DevModeConfig.mjs index c03457f..1dc2833 100644 --- a/module/classes/DevModeConfig.mjs +++ b/module/classes/DevModeConfig.mjs @@ -164,6 +164,10 @@ export class DevModeConfig extends FormApplication { packageSpecificDebugFormData, debugOverrideFormData, overrideConfigDebug: game.settings.get(DevMode.MODULE_ID, DevMode.SETTINGS.overrideConfigDebug), + actorTypes: game.system.template.Actor.types.reduce((types, type) => { + types[type] = `ACTOR.Type${type.capitalize()}`; + return types; + }, {}), }; DevMode.log(false, data, { @@ -188,9 +192,8 @@ export class DevModeConfig extends FormApplication { switch (event.currentTarget?.dataset?.action) { case 'actorCRUD': { - const inputVal = html.find('input[name="actorCrudIterations"]').val(); - console.log('inputVal', inputVal); - return DevModePerformance.actorCRUDTest(inputVal || undefined); + const formData = expandObject(new FormDataExtended(event.currentTarget.closest('form')).toObject()); + return DevModePerformance.actorCRUDTest(formData.actorCrud); } default: return; diff --git a/module/classes/DevModePerformance.mjs b/module/classes/DevModePerformance.mjs index a18dfe5..dd8846f 100644 --- a/module/classes/DevModePerformance.mjs +++ b/module/classes/DevModePerformance.mjs @@ -17,14 +17,15 @@ export class DevModePerformance { }); } - static actorCRUDTest = async (iterations = 1000) => { - console.log('running test with iterations:', `${iterations}`, !!iterations, iterations || 1000); + static actorCRUDTest = async ({ type, iterations = 1000 } = {}) => { + if (!game.system.template.Actor.types.includes(type)) return console.error(type, "is invalid actor type"); + console.log(`Running CRUD test on "${type}" type with ${iterations} iterations`); const debugConfig = { ...CONFIG.debug }; this.resetDebug(); const now = performance.now(); for (let x = 0; x <= iterations; x++) { - const created = await Actor.create({ name: `${x}`, type: 'npc' }); + const created = await Actor.create({ name: `${x}`, type }); await created.update({ name: 'Actor' + x }); await created.delete(); if (x % 10 == 0) SceneNavigation.displayProgressBar({ label: 'Test Progress', pct: (x / iterations) * 100 }); diff --git a/templates/settings.hbs b/templates/settings.hbs index e433a60..f76ac85 100644 --- a/templates/settings.hbs +++ b/templates/settings.hbs @@ -85,12 +85,18 @@

{{localize 'DEV.configMenu.performance.hint'}}

-

{{localize - 'DEV.configMenu.performance.actorCRUD.label'}}

+

{{localize 'DEV.configMenu.performance.actorCRUD.label'}}

+
+ + +