Profiling Scripts with AQtime: Part 1 - Web Scripts.
The recent version of AQtime (version 6.0)
introduces the ability to profile scripts executed by the Microsoft Scripting
Engine. This scripting engine appeared in Microsoft Windows 98 and since then, is supplied with all of their operating systems. That is why it became a
de-facto standard for a vast number of client applications. For example, this
engine is employed by Microsoft Internet Explorer, Windows Script Host (this
utility allows you to run scripts directly from Windows) and by AutomatedQA’s TestComplete.
You can now use AQtime to improve and
examine web scripts, Windows Script Host tasks, TestComplete project scripts and
other scripts. At this time the script profiling is available for the
Performance, Coverage and Function Trace profilers.
This article demonstrates the first of the
mentioned possible tasks - profiling scripts from web pages.
What is a Web Script?
Web scripts are a set of JScript or VBScript
instructions that are executed by the web-browser on the client side. Web
scripts are intended to customize the appearance of the web pages and to
introduce user interaction which is unreachable via static HTML pages.
Web scripts are often embedded within an HTML
document (in the <script> tags), but also they may reside in a separate
file (.js or .vb extensions). Both the ASCII and Unicode encodings are possible.
Enabling Script Debug Mode in a Browser
AQtime tracks the debug information that is
passed to the Microsoft Scripting Engine. Therefore, in order to obtain
profiling results in AQtime, Internet Explorer should generate debug
information. To enable debug mode in your browser do the following:
- Open the Control
- Select Internet Options.
- Switch to the Advanced page of the ensuing Internet Options dialog.
- Clear the Disable Script Debugging (Internet Explorer) and Disable Script Debugging (Other)
check boxes in the Browsing
AQtime offers three ways to profile
a web script. They differ in how the profiled module is defined, it can be: a
web-browser, a page’s URL or a script source file.
Profiling a script via web-browser
The first technique is the elementary. You
simply add Internet Explorer’s executable (iexplore.exe) to the Modules
pane and enable the “Profile Entire
Script” option. No other options or parameters are required, just choose
the Performance, Coverage or Function Trace profiler and start profiling.
Upon start, the browser is launched and you
manually navigate to whatever page you want. Once the profiling is finished,
AQtime will report both the application’s results and the results for all
executed scripting routines.
Profiling a script via URL
The Modules pane AQtime version 6 has
a special button and context menu item named Add URL. It allows you to profile scripts directly from the web pages.
A page can be on the Internet, on a local network or on a local computer.
Upon pressing the Add URL button (or
selecting the menu item of the same name) a dialog appears asking you for the page
location. When the page address is provided, AQtime performs a number of
actions automatically: connects to the given URL, retrieves the list of
available routines, displays them in the Modules pane, and assigns Internet
Explorer as the host application. After
that you can create custom profiling areas to profile some of the available
routines, or enable the “Profile Entire
Script” option to profile all of the routines from the web page. Then you can
select a profiler and start profiling.
Upon start, the browser is launched and the
desired page is loaded automatically. Once
the profiling is finished, AQtime will report the results for the
Profiling a script via source file
This technique is pretty much the same as adding
executables, libraries and assemblies of ordinary applications. Since this
way is more universal, it requires additional parameters to profile a script, but it also offers alol of the profiling features.
The sequence of actions is as follows: You
locate the .js or . vb file that holds the desired script and add it as the
module via the Add Module
button/menu item. AQtime then retrieves the list of available routines and
displays them in the Modules pane. Thus you can create new profiling areas and
add the interested routines to these areas, or enable the “Profile Entire Script” option to profile all of the routines from the
added source file. After that you need to open the Run parameters dialog, specify
Internet Explorer as the host application and the page’s path or URL as
additional parameter. That’s it! You can then select the profiler and start
Upon start, the browser is launched and the
desired page is loaded automatically.
Once the profiling is finished, AQtime will report the results for
the scripting routines.
I hope you enjoyed this article and stay tuned for Part 2.