Skip to content

Commit

Permalink
fixed several performance and timeout issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Nico-Duduf committed May 23, 2022
1 parent 5fbcf9f commit 5317553
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 18 deletions.
51 changes: 42 additions & 9 deletions inc/api/core.jsxinc
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,12 @@ DuSanity.setEnabled = function (test, enabled)
{
if (enabled)
{
//First run
//First run
test();
var timeOut = parseInt(DuESF.settings.data.sanity.timeOut[test.stringId]);
if (DuESF.debug) timeOut = 3000;
//Event
test.id = DuScriptUI.addEvent(test, timeOut);
test.enabled = true;
}
else
{
DuScriptUI.removeEvent(test.id);
test.id = 0;
test.enabled = false;
}
}
Expand Down Expand Up @@ -174,6 +168,31 @@ DuSanity.setTimeOut = function (test, timeOut)
DuSanity.setEnabled(test, enabled);
}

/**
* Runs a test
* @param {boolean} [dontFix=false] If false, will automatically fix the issue.
* @param {boolean} [force=false] To improve performance, the test may be automatically paused. Set this to true to force it to run if calling this method.
* @return {DuSanity.Level} The level of the result of the test.
*/
DuSanity.runTest = function(test, dontFix, force) {
dontFix = def(dontFix, false);
force = def(force, false);

var elapsed = Date.now() - test.lastRun;
var timedOut = elapsed > test.timeOut;

var result = test.currentLevel;

if (force || timedOut) {
result = test(dontFix, force);
test.lastRun = Date.now();
}

if(DuSanity.currentLevel < result) DuSanity.currentLevel = result;

return result;
}

//low-level undocumented function: checks a value against a limit and sets the results in the UI
//returns the level
DuSanity.checkLevel = function(value, limit)
Expand Down Expand Up @@ -262,6 +281,7 @@ DuSanity.Test.compNames = function ( dontFix, force ) {
return DuSanity.fix( DuSanity.Test.compNames );

}
DuSanity.Test.compNames.lastRun = 0;
DuSanity.Test.compNames.stringId = 'compNames';
DuSanity.Test.compNames.testName = 'Composition Names';
DuSanity.Test.compNames.info = '';
Expand Down Expand Up @@ -326,6 +346,7 @@ DuSanity.Test.layerNames = function ( dontFix ) {
return DuSanity.fix( DuSanity.Test.layerNames );

}
DuSanity.Test.layerNames.lastRun = 0;
DuSanity.Test.layerNames.stringId = 'layerNames';
DuSanity.Test.layerNames.testName = 'Layer Names';
DuSanity.Test.layerNames.info = '';
Expand Down Expand Up @@ -358,6 +379,7 @@ DuSanity.Test.layerNames.fix = function() {
*/
DuSanity.Test.expressionEngine = function ( dontFix ) {
dontFix = def(dontFix, false);

var e = DuAEProject.expressionEngine();
if (e.indexOf("javascript") == 0)
{
Expand All @@ -376,6 +398,7 @@ DuSanity.Test.expressionEngine = function ( dontFix ) {
return DuSanity.fix( DuSanity.Test.expressionEngine );

}
DuSanity.Test.expressionEngine.lastRun = 0;
DuSanity.Test.expressionEngine.stringId = 'expressionEngine';
DuSanity.Test.expressionEngine.testName = 'Expression engine';
DuSanity.Test.expressionEngine.info = '';
Expand Down Expand Up @@ -427,6 +450,7 @@ DuSanity.Test.projectSize = function ( dontFix ) {
if (dontFix) return DuSanity.Test.projectSize.currentLevel;
return DuSanity.fix( DuSanity.Test.projectSize );
}
DuSanity.Test.projectSize.lastRun = 0;
DuSanity.Test.projectSize.stringId = 'projectSize';
DuSanity.Test.projectSize.testName = 'Project size';
DuSanity.Test.projectSize.info = '';
Expand All @@ -439,7 +463,7 @@ DuSanity.Test.projectSize.hasAutoFix = false;
DuSanity.Test.projectSize.timeOut = 60000;
DuSanity.Test.projectSize.options = {
sizeLimit: {
value: 20,
value: 100,
description: DuScriptUI.String.SIZE_LIMIT
}
}
Expand All @@ -461,6 +485,7 @@ DuSanity.Test.projectItems = function ( dontFix ) {
if (dontFix) return DuSanity.Test.projectItems.currentLevel;
return DuSanity.fix( DuSanity.Test.projectItems );
}
DuSanity.Test.projectItems.lastRun = 0;
DuSanity.Test.projectItems.stringId = 'projectItems';
DuSanity.Test.projectItems.testName = 'Project items';
DuSanity.Test.projectItems.info = '';
Expand All @@ -473,7 +498,7 @@ DuSanity.Test.projectItems.hasAutoFix = false;
DuSanity.Test.projectItems.timeOut = 600000;
DuSanity.Test.projectItems.options = {
itemsLimit: {
value: 400,
value: 1000,
description: DuScriptUI.String.ITEMS_LIMIT
}
}
Expand Down Expand Up @@ -559,6 +584,7 @@ DuSanity.Test.itemSources = function ( dontFix, force ) {
if (dontFix) return DuSanity.Test.itemSources.currentLevel;
return DuSanity.fix( DuSanity.Test.itemSources );
}
DuSanity.Test.itemSources.lastRun = 0;
DuSanity.Test.itemSources.stringId = 'itemSources';
DuSanity.Test.itemSources.testName = 'Duplicated footages';
DuSanity.Test.itemSources.info = '';
Expand Down Expand Up @@ -601,6 +627,7 @@ DuSanity.Test.unusedItems = function ( dontFix ) {
if (dontFix) return DuSanity.Test.unusedItems.currentLevel;
return DuSanity.fix( DuSanity.Test.unusedItems );
}
DuSanity.Test.unusedItems.lastRun = 0;
DuSanity.Test.unusedItems.stringId = 'unusedItems';
DuSanity.Test.unusedItems.testName = 'Unused footages';
DuSanity.Test.unusedItems.info = '';
Expand Down Expand Up @@ -651,6 +678,7 @@ DuSanity.Test.precomps = function ( dontFix ) {
if (dontFix) return DuSanity.Test.precomps.currentLevel;
return DuSanity.fix( DuSanity.Test.precomps );
}
DuSanity.Test.precomps.lastRun = 0;
DuSanity.Test.precomps.stringId = 'precomps';
DuSanity.Test.precomps.testName = 'Precompositions';
DuSanity.Test.precomps.info = '';
Expand Down Expand Up @@ -715,6 +743,7 @@ DuSanity.Test.unusedComps = function ( dontFix ) {
if (dontFix) return DuSanity.Test.unusedComps.currentLevel;
return DuSanity.fix( DuSanity.Test.unusedComps );
}
DuSanity.Test.unusedComps.lastRun = 0;
DuSanity.Test.unusedComps.stringId = 'unusedComps';
DuSanity.Test.unusedComps.testName = 'Main compositions';
DuSanity.Test.unusedComps.info = '';
Expand Down Expand Up @@ -809,6 +838,7 @@ DuSanity.Test.memory = function ( dontFix ) {
if (dontFix) return DuSanity.Test.memory.currentLevel;
return DuSanity.fix( DuSanity.Test.memory );
}
DuSanity.Test.memory.lastRun = 0;
DuSanity.Test.memory.stringId = 'memory';
DuSanity.Test.memory.testName = 'Memory in use';
DuSanity.Test.memory.info = '';
Expand Down Expand Up @@ -855,6 +885,7 @@ DuSanity.Test.essentialProperties = function ( dontFix ) {
if (dontFix) return DuSanity.Test.essentialProperties.currentLevel;
return DuSanity.fix( DuSanity.Test.essentialProperties );
}
DuSanity.Test.essentialProperties.lastRun = 0;
DuSanity.Test.essentialProperties.stringId = 'essentialProperties';
DuSanity.Test.essentialProperties.testName = 'Essential properties';
DuSanity.Test.essentialProperties.info = '';
Expand Down Expand Up @@ -924,6 +955,7 @@ DuSanity.Test.save = function ( dontFix ) {
if (dontFix) return DuSanity.Test.save.currentLevel;
return DuSanity.fix( DuSanity.Test.save );
}
DuSanity.Test.save.lastRun = 0;
DuSanity.Test.save.stringId = 'save';
DuSanity.Test.save.testName = 'Time since last save';
DuSanity.Test.save.info = '';
Expand Down Expand Up @@ -969,6 +1001,7 @@ DuSanity.Test.upTime = function ( dontFix ) {
if (dontFix) return DuSanity.Test.upTime.currentLevel;
return DuSanity.fix( DuSanity.Test.upTime );
}
DuSanity.Test.upTime.lastRun = 0;
DuSanity.Test.upTime.stringId = 'upTime';
DuSanity.Test.upTime.testName = 'Up time';
DuSanity.Test.upTime.info = '';
Expand Down
7 changes: 4 additions & 3 deletions inc/api/init.jsxinc
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ DuSanity.run = function( force ) {
for (var k in DuSanity.Test) {
if (!DuSanity.Test.hasOwnProperty(k)) continue;
var test = DuSanity.Test[k];
if (test.enabled) {
if (DuSanity.isEnabled(test)) {
var testLevel = test.currentLevel;
if (force) testLevel = test();
testLevel = DuSanity.runTest(test, false, force);
if (testLevel > level) level = testLevel;
}
}
Expand All @@ -38,7 +38,8 @@ DuSanity.run = function( force ) {
*/
DuSanity.init = function() {
// A single global variable to keep track of Ae Uptime
$.global.DuSan_AEStartTime = def($.global.DuSan_AEStartTime, Date.now());
$.global.DuSan = def($.global.DuSan, {});
$.global.DuSan.AEStartTime = def($.global.DuSan.AEStartTime, Date.now());

// Defaults
DuESF.settings.data.sanity = def(DuESF.settings.data.sanity, {});
Expand Down
4 changes: 2 additions & 2 deletions inc/api/scriptui.jsxinc
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ DuSanity.UI.panel = function(container) {
orientation: 'row'
});
runAllButton.alignment = ['fill', 'top'];
runAllButton.onCLick = function() { DuSanity.run(true); };
runAllButton.onClick = function() { DuSanity.run(true); };
}

/**
Expand Down Expand Up @@ -287,7 +287,7 @@ DuSanity.UI.test = function (container, test) {
helpTip: DuScriptUI.String.RUN_TEST_TIP
});
refreshButton.alignment = ['right', 'center'];
refreshButton.onClick = function() { test(undefined, true); updateUI(); };
refreshButton.onClick = function() { DuSanity.runTest( test, false, true ); updateUI(); };

var optionsButton = DuScriptUI.button(group, {
text: '',
Expand Down
2 changes: 1 addition & 1 deletion inc/config/api_version.jsxinc
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* @namespace
* @author Nicolas Dufresne and contributors
* @copyright 2022 Nicolas Dufresne, RxLaboratory
* @version 2.0.0-Dev
* @version 2.0.1
* @requires DuAEF>=1.0.0
* @license GPL-3.0 <br />
* DuSan is free software: you can redistribute it and/or modify<br />
Expand Down
2 changes: 1 addition & 1 deletion inc/config/version.jsxinc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var isPreRelease = true;
var scriptName = "DuSan";
var scriptVersion = "2.0.0-Dev";
var scriptVersion = "2.0.1";
var scriptAbout = 'Sanity tests.';
var companyName = "RxLaboratory";

Expand Down
2 changes: 1 addition & 1 deletion inc/mainPanel.jsxinc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function buildMainPanelUI( tab )
{
DuSanity.UI.panel(tab);
DuSanity.UI.panel(tab);
}
4 changes: 3 additions & 1 deletion src-docs/docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

## ▹ 2.0.1

Improved performance. Some tests may be paused when the project is too big; they can still be run manually.
- Improved performance. Some tests may be paused when the project is too big; they can still be run manually.
- Fixed an issue where the tests would be run continuously.
- Fixed the *Run all tests* button not working.

## ▹ 2.0.0

Expand Down

0 comments on commit 5317553

Please sign in to comment.