Difference between revisions of "Performance Profiler library"
Jhernandez3 (talk | contribs) (Created page with "Category:Analytica User Guide <breadcrumbs>Analytica User Guide > {{PAGENAME}}</breadcrumbs><br /> The Performance Profiler library shows you the computation time and mem...") |
Jhernandez3 (talk | contribs) m |
||
Line 5: | Line 5: | ||
First add Performance Profiler.ana from the Libraries folder into your model. | First add Performance Profiler.ana from the Libraries folder into your model. | ||
+ | |||
+ | ::[[File:performance_profiler_1.png|300px]] | ||
+ | |||
+ | Now display the results (table or graph) for the variables whose performance you want to profile. Open the library, and click '''Performance profiles'''. | ||
+ | |||
+ | ::[[File:performance_profiler_2.png|400px]] | ||
+ | |||
+ | This table lists the variables and functions by row, with the class of the object, parent module, Bytes of RAM (random access memory), and CPU msecs (milliseconds of time used by the central processing unit). The last column, msecs w ancestors, shows the CPU milliseconds to compute each variable or function including all its ancestors — i.e., the variables and functions it uses. The Profiler shows all variables and functions that use more than 24 bytes of RAM (the minimum) or take more than 1 millisecond to compute. Use Sort objects by to sort the table by any column. | ||
+ | |||
+ | If you want to inspect a variable or function to see why it’s taking so much time or memory, just click its title in the .Objects index column to open its Object window. | ||
+ | |||
+ | ==Update profiles== | ||
+ | |||
+ | After computing more results, click this button to update the performance profile to reflect the additional time and memory used. | ||
+ | |||
+ | ==Zero out times== | ||
+ | |||
+ | If you want to look at the incremental time used by additional results, or another computation, first click this button to zero out the times already computed. | ||
+ | |||
+ | ==Understanding memory usage== | ||
+ | |||
+ | For complex definitions, it might use much more RAM while it is computing than it needs to cache the final result — the Profiler reports only the latter. The Bytes show the RAM used to store the value of each variable, mid, probabilistic, or both, depending on which it has computed. Typically, an array takes about 12 bytes per number to store. For example, an uncertain dynamic array of numbers, with an index I of 20 elements, Time has 30 elements, and Samplesize = 1000, would use about 20 x 30 x 1000 x12 = 7,200,000 bytes or 7.2 Megabytes. Analytica uses an efficient representation for arrays with many zeroes (sparse arrays) or many repeated values. An array that is an exact or partial copy of another array can share slices. In such cases, it might actually use less memory than it reports. | ||
+ | |||
+ | ==Understanding computation time== | ||
+ | |||
+ | The CPU time listed is the time it took to evaluate the mid and/or prob value of each variable or function, depending on which type of evaluation it did. It is zero if the results computed did not cause evaluation of the variable or function. A variable is usually only computed at most once each for its mid and prob value. Rare exceptions include when the variable is referenced directly or indirectly in a parameter to Whatif or WhatIfall, which might cause multiple evaluations. A function can be called many times. The CPU time reported is the sum over all these evaluations. | ||
+ | |||
+ | ==Time and virtual memory== | ||
+ | |||
+ | Like most 32-bit applications on Windows, Analytica can use up to 3 GB of memory. If your computer doesn’t have that much RAM installed, and it needs more than is available, it can use virtual memory — that is, it saves data onto the hard disk. Since reading and writing a hard disk is usually much slower than RAM, using virtual memory often causes the application to slow down substantially. In this case, finding a way to reduce memory usage below the amount of physical RAM available can speed up the application considerably. Another approach is to install more RAM, up to 4 GB. | ||
+ | |||
+ | Performance profiling attributes and function | ||
+ | |||
+ | The Performance Profiler library uses a function, two attributes, and a command, which are also available for you to write your own functions using memory or time. For an example of how to use them, you can open up the library. | ||
+ | |||
+ | MemoryInUseBy(v) | ||
+ | |||
+ | This function returns the number of bytes in use by the cached result(s) for variable v — with the same disclaimer that shared memory can be counted more than once. It includes memory used by mid and prob values if those results have been computed and cached, but it doesn’t force them to be computed if they haven’t been. | ||
+ | |||
+ | This function includes these two special read-only attributes: | ||
+ | |||
+ | ===EvaluationTime=== | ||
+ | |||
+ | This attribute returns the time in seconds to evaluate its variable or function, not including the time to evaluate any of its inputs. | ||
+ | |||
+ | ===EvaluationTimeAll=== | ||
+ | |||
+ | This attribute returns the time in seconds to evaluate its variable or function, including the time to compute any of its inputs that needed to | ||
+ | be evaluated (and their inputs, and so on). | ||
+ | |||
+ | ==ResetElapsedTimings== | ||
+ | |||
+ | This command sets these attributes back to zero. Like any command, you can use it in a button script, the Typescript, but not in a regular definition. | ||
+ | |||
+ | <Tip Title="Tip"> These features, including the Performance Profiler are only available for Analytica Enterprise, Power Player, and ADE editions.</Tip> | ||
<footer>Huge Arrays / {{PAGENAME}} / RunConsoleProcess - call other applications</footer> | <footer>Huge Arrays / {{PAGENAME}} / RunConsoleProcess - call other applications</footer> |
Revision as of 07:01, 26 December 2015
The Performance Profiler library shows you the computation time and memory space used by each variable and function. If you have a large model that takes a long time to run or uses a lot of memory, you might want to find out which variables or functions are using the Lion’s share of the time or memory. As experienced programmers know, the results are often a surprise. With the results from the Performance Profiler, you know where to focus your efforts to make the model faster or use less RAM.
First add Performance Profiler.ana from the Libraries folder into your model.
Now display the results (table or graph) for the variables whose performance you want to profile. Open the library, and click Performance profiles.
This table lists the variables and functions by row, with the class of the object, parent module, Bytes of RAM (random access memory), and CPU msecs (milliseconds of time used by the central processing unit). The last column, msecs w ancestors, shows the CPU milliseconds to compute each variable or function including all its ancestors — i.e., the variables and functions it uses. The Profiler shows all variables and functions that use more than 24 bytes of RAM (the minimum) or take more than 1 millisecond to compute. Use Sort objects by to sort the table by any column.
If you want to inspect a variable or function to see why it’s taking so much time or memory, just click its title in the .Objects index column to open its Object window.
Update profiles
After computing more results, click this button to update the performance profile to reflect the additional time and memory used.
Zero out times
If you want to look at the incremental time used by additional results, or another computation, first click this button to zero out the times already computed.
Understanding memory usage
For complex definitions, it might use much more RAM while it is computing than it needs to cache the final result — the Profiler reports only the latter. The Bytes show the RAM used to store the value of each variable, mid, probabilistic, or both, depending on which it has computed. Typically, an array takes about 12 bytes per number to store. For example, an uncertain dynamic array of numbers, with an index I of 20 elements, Time has 30 elements, and Samplesize = 1000, would use about 20 x 30 x 1000 x12 = 7,200,000 bytes or 7.2 Megabytes. Analytica uses an efficient representation for arrays with many zeroes (sparse arrays) or many repeated values. An array that is an exact or partial copy of another array can share slices. In such cases, it might actually use less memory than it reports.
Understanding computation time
The CPU time listed is the time it took to evaluate the mid and/or prob value of each variable or function, depending on which type of evaluation it did. It is zero if the results computed did not cause evaluation of the variable or function. A variable is usually only computed at most once each for its mid and prob value. Rare exceptions include when the variable is referenced directly or indirectly in a parameter to Whatif or WhatIfall, which might cause multiple evaluations. A function can be called many times. The CPU time reported is the sum over all these evaluations.
Time and virtual memory
Like most 32-bit applications on Windows, Analytica can use up to 3 GB of memory. If your computer doesn’t have that much RAM installed, and it needs more than is available, it can use virtual memory — that is, it saves data onto the hard disk. Since reading and writing a hard disk is usually much slower than RAM, using virtual memory often causes the application to slow down substantially. In this case, finding a way to reduce memory usage below the amount of physical RAM available can speed up the application considerably. Another approach is to install more RAM, up to 4 GB.
Performance profiling attributes and function
The Performance Profiler library uses a function, two attributes, and a command, which are also available for you to write your own functions using memory or time. For an example of how to use them, you can open up the library.
MemoryInUseBy(v)
This function returns the number of bytes in use by the cached result(s) for variable v — with the same disclaimer that shared memory can be counted more than once. It includes memory used by mid and prob values if those results have been computed and cached, but it doesn’t force them to be computed if they haven’t been.
This function includes these two special read-only attributes:
EvaluationTime
This attribute returns the time in seconds to evaluate its variable or function, not including the time to evaluate any of its inputs.
EvaluationTimeAll
This attribute returns the time in seconds to evaluate its variable or function, including the time to compute any of its inputs that needed to be evaluated (and their inputs, and so on).
ResetElapsedTimings
This command sets these attributes back to zero. Like any command, you can use it in a button script, the Typescript, but not in a regular definition.
Enable comment auto-refresher