X-Cart:X-Cart Benchmark report tool
A built-in tool for the measurement of the time of code execution is available in X-Cart starting with X-Cart version 4.1.x. For X-Cart 4.0.x versions, a special patch is available to get this tool.
Time measurements are based on the following control points:
- in the beginning of script execution (in top.inc.php);
- in db_query() - before making an SQL-request and after it;
- in the function func_display;
- in the end of script execution (a function __debug() is created and registered via register_shutdown_function).
That way, the following measurements are performed:
- duration of time between two consecutive control points;
- total time for the execution of all the SQL-requests;
- time of PHP code execution without Smarty;
- Smarty operation time;
- total script execution time.
The Benchmark tool can be enabled and configured using the following constants in the file top.inc.php:
- BENCH - whether the tool is enabled or not.
- BENCH_SIMPLE - perform measurements, but not display the results - only write the results to the binary log (if the BENCH_BLOCK_SAVE_BIN constant is disabled).
- BENCH_BACKTRACE - show backtrace information (The information is displayed when hovering the mouse cursor over a record number in the Benchmark report. This feature is not available in Firefox).
- BENCH_LOG_SUMMARY - write general performance information to .log file.
- BENCH_LOG_TIME_LIMIT - sets a limit (in seconds) defining which records should be written to log file. If the duration of the time period pertaining to a record exceeds the limit set by this constant, it will be written to log.
- BENCH_LOG_TYPE_LIMIT - limits the type of records that can be written to log. The allowed types should be entered as a comma-separated list like so: PHP, SMARTY, SQL.
- BENCH_DISPLAY_TYPE - report type (will be shown at the bottom of the page: T - only the totals; F - full (totals + report); A - advanced (includes the result of the EXPLAIN command for SQL-requests).
- BENCH_TIME_LIMIT - sets a limit (in seconds) defining which records should be displayed at the bottom of the page. If the duration of the time period pertaining to a record exceeds the limit set by this constant, it will be shown in the report.
- BENCH_MEM_LIMIT - sets a limit (in megabytes) defining which records should be displayed at the bottom of the page. If a record shows a memory use increase exceeding the limit set by this constant, it will be shown in the report.