Adobe 27510753 Scripting Guide - Page 62

Profiling, Functions, Lines, Add Timing Info, No Profiler Data, Show Hit Count, Show Timing

Page 62 highlights

54 Using ExtendScript Tools and Features Adobe InDesign CS2 Scripting Guide Profiling The Profiling tool helps you to optimize program execution. When you turn profiling on, the JavaScript engine collects information about a program while it is running. It counts how often the program executed a line or function, or how long it took to execute a line or function. You can choose exactly which profiling data to display. Because profiling significantly slows execution time, the Profile menu offers these profiling options. Off Functions Lines Add Timing Info No Profiler Data Show Hit Count Show Timing Erase Profiler Data Save Data As Profiling turned off. This is the default. The profiler counts each function call. At the end of execution, displays the total to the left of the line number where the function header is defined. The profiler counts each time each line is executed. At the end of execution, displays the total to the left of the line number. Consumes more execution time, but delivers more detailed information. Instead of counting the functions or lines, records the time taken to execute each function or line. At the end of execution, displays the total number of microseconds spent in the function or line, to the left of the line number. This is the most time-consuming form of profiling. When selected, do not display profiler data. When selected, display hit counts. When selected, display timing data. Clear all profiling data. Save profiling data as comma-separated values in a CSV file that can be loaded into a spreadsheet program such as Excel. When execution halts (at termination, at a breakpoint, or due to a runtime error), the Toolkit displays this information in the Editor, line by line. The profiling data is color coded: l Green indicates the lowest number of hits, or the fastest execution time. l Red indicates trouble spots, such as a line that has been executed many times, or which line took the most time to execute. This example displays timing information for the program, where the fastest line took 4 microseconds to execute, and the slowest line took 29 microseconds. The timing might not be accurate down to the microsecond; it depends on the resolution and accuracy of the hardware timers built into your computer.

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 103
  • 104
  • 105
  • 106
  • 107
  • 108
  • 109
  • 110
  • 111
  • 112
  • 113
  • 114
  • 115
  • 116
  • 117
  • 118
  • 119
  • 120
  • 121
  • 122
  • 123
  • 124
  • 125
  • 126
  • 127
  • 128
  • 129
  • 130
  • 131
  • 132
  • 133
  • 134
  • 135
  • 136
  • 137
  • 138
  • 139
  • 140
  • 141
  • 142
  • 143
  • 144
  • 145
  • 146
  • 147
  • 148
  • 149
  • 150
  • 151
  • 152
  • 153
  • 154
  • 155
  • 156
  • 157
  • 158
  • 159
  • 160
  • 161
  • 162
  • 163
  • 164
  • 165
  • 166
  • 167
  • 168
  • 169
  • 170
  • 171
  • 172
  • 173
  • 174
  • 175
  • 176
  • 177
  • 178
  • 179
  • 180
  • 181
  • 182
  • 183
  • 184

54
Using ExtendScript Tools and Features
Adobe InDesign CS2 Scripting Guide
Profiling
The Profiling tool helps you to optimize program execution. When you turn profiling on, the JavaScript engine
collects information about a program while it is running. It counts how often the program executed a line
or function, or how long it took to execute a line or function. You can choose exactly which profiling data to
display.
Because profiling significantly slows execution time, the Profile menu offers these profiling options.
Off
Profiling turned off. This is the default.
Functions
The profiler counts each function call. At the end of execution, displays the total
to the left of the line number where the function header is defined.
Lines
The profiler counts each time each line is executed. At the end of execution,
displays the total to the left of the line number.
Consumes more execution time, but delivers more detailed information.
Add Timing Info
Instead of counting the functions or lines, records the time taken to execute
each function or line. At the end of execution, displays the total number of mi-
croseconds spent in the function or line, to the left of the line number.
This is the most time-consuming form of profiling.
No Profiler Data
When selected, do not display profiler data.
Show Hit Count
When selected, display hit counts.
Show Timing
When selected, display timing data.
Erase Profiler Data
Clear all profiling data.
Save Data As
Save profiling data as comma-separated values in a CSV file that can be loaded
into a spreadsheet program such as Excel.
When execution halts (at termination, at a breakpoint, or due to a runtime error), the Toolkit displays this
information in the Editor, line by line. The profiling data is color coded:
Green indicates the lowest number of hits, or the fastest execution time.
Red indicates trouble spots, such as a line that has been executed many times, or which line took the most
time to execute.
This example displays timing information for the program, where the fastest line took 4 microseconds
to execute, and the slowest line took 29 microseconds. The timing might not be accurate down to the
microsecond; it depends on the resolution and accuracy of the hardware timers built into your computer.
l
l