Performance Issues - Adobe GoLive CS2 Programmer's Manual

Hide thumbs Also See for GoLive CS2:
Table of Contents

Advertisement

SDK Programmer's Guide
To operate on the data passed as the script evaluation's result, the myExtFn function must extract it from
the returnValue pointer in a format that suits your development goals. To do so, pass the
returnValue pointer to the JSAValueToXx method that returns your preferred data type. In the
current example, the result of the evaluation is a character string that is the HTML representation of the
entire document. To extract this character string from the returnValue pointer, the body of the
myExtFn function passes the returnValue pointer to the JSAValueToString function.
char* pTheSource;
JSAEval("document.documentElement.getOuterHTML()", returnValue, -1);
pTheSource = JSAValueToString(returnValue);
If the result of scriptlet evaluation is not to be the myExtFn function's return value, the myExtFn function
must clear this result from the returnValue pointer before exiting. To set the myExtFn function's result,
pass the returnValue pointer to the JSAXxToValue function that implements your return value's data
type as a JSValue pointer. In the current example, the myExtFn function passes the returnValue
pointer to the JSAUndefinedToValue function, which causes the myExtFn function to return an
undefined result. To return integer, Boolean, string, or double values, call the appropriate JSAXxToValue
function.
JSAUndefinedToValue(returnValue);

Performance Issues

Code that takes a long time to return control to GoLive may interfere with the execution of timed scripts
scheduled by the
that permits regular calls to the
each of the currently queued timed scriptlets a chance to execute. If a scriptlet's specified delay has
elapsed, it executes at this time. Once each queued scriptlet has had its opportunity to execute or
continue waiting, the JSAPoll function returns control to the lengthier task that called it.
The amount of time required to complete a function call can be a useful metric for measuring code
performance. You can measure this by using the JavaScript Date object to get the system time in
milliseconds immediately before and after calling a function to be tested.
This example tests the execution speed of scripted and compiled versions of the same function.
// measure time for script fn to complete
var startTime = new Date();
startTime = startTime.getTime();
myScriptFunction(); // replace with your own script function
var stopTime = new Date();
stopTime = stopTime.getTime();
var elapsed = (stopTime - startTime);
writeln("Script code completed in " + elapsed + " milliseconds.");
// measure time for compiled fn to complete
var eStartTime= new Date();
startTime = eStartTime.getTime();
// assume the compiled fn is built into myExtLib.dll
myExtLib.myCompiledFunction(); // replace with your own compiled fn
var eStopTime = new Date();
eStopTime = eStopTime.getTime();
var elapsed2 = (eStopTime - eStartTime);
writeln("Compiled code completed in " + elapsed2 + " milliseconds.");
var diff = (elapsed - elapsed2);
Adobe GoLive CS2 SDK
function. To avoid such timeout errors, structure lengthy tasks in a manner
startTimer
JSAPoll
function during their execution. The JSAPoll function gives
Using External Libraries
186

Advertisement

Table of Contents
loading

Table of Contents