Difference between revisions of "X-Cart:X-Cart Benchmark report tool"

From X-Cart 4 Classic
Jump to: navigation, search
m
m
 
(One intermediate revision by the same user not shown)
Line 11: Line 11:
  
 
:* duration of time between two consecutive control points;
 
:* duration of time between two consecutive control points;
:* total time for the execution of all the SQL-requests;
+
:* total time for the execution of all the SQL requests;
 
:* time of PHP code execution without Smarty;
 
:* time of PHP code execution without Smarty;
 
:* Smarty operation time;
 
:* Smarty operation time;
Line 54: Line 54:
 
Example:
 
Example:
  
FULL TIME: 3.1977
+
FULL TIME: 3.1977 <br />
Start time: 08/11/2005 17:48:20
+
Start time: 08/11/2005 17:48:20 <br />
Start memory: 0.132
+
Start memory: 0.132 <br />
  
 
{| class="wikitable"
 
{| class="wikitable"
Line 72: Line 72:
 
|4.521
 
|4.521
 
|0.002
 
|0.002
|
+
|SELECT name, value, category FROM xcart_config
|
+
|-
 +
|3
 +
|0.0476
 +
|0.170
 +
| -
 +
|-
 +
|4
 +
|0.0244
 +
|0.002
 +
|SELECT count(*) FROM xcart_sessions_data WHERE sessid='edc4f4c374e3a562e8891e14e00d2afc'
 +
|-
 +
|5
 +
|0.0002
 +
|0.000
 +
| -
 +
|-
 +
|6
 +
|0.0008
 +
|0.002
 +
|DELETE FROM xcart_sessions_data WHERE expiry<'1123768101'
 +
|-
 +
|81
 +
|0.0013
 +
|0.015
 +
| -
 +
|-
 +
|82
 +
|0.0288
 +
|0.003
 +
|SELECT xcart_products.productid, xcart_products.product, xcart_products.productcode, xcart_products.avail, MIN(xcart_pricing.price) AS price, xcart_product_features.fclassid, IF(xcart_product_features.fclassid IS NULL...
 +
|-
 +
|83
 +
|0.0003
 +
| -0.026
 +
| -
 +
|-
 +
|84
 +
|0.0719
 +
|0.001
 +
|SELECT name, value FROM xcart_languages WHERE code = 'US' AND name IN ('lbl_sku','lbl_product','lbl_price','lbl_default')
 +
|-
 +
|85
 +
|0.4190
 +
|0.271
 +
| -
 
|}
 
|}
 +
 +
SQL time: 2.4501 (76.62%) <br />
 +
PHP time: 0.2571 (8.04%) <br />
 +
Smarty time: 0.4910 (15.35%) <br />
 +
Used memory: 6.415Mb <br />
 +
 +
 +
[[Category:X-Cart developer guide]]

Latest revision as of 12:32, 30 November 2017

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.

The measurement results are output onto the screen in the form of a table (the output code comes in the __debug function). The format is as follows:

# Index of execution of a control point in order
Time Time period between the execution of the current control point and the following one
Memory Memory use dynamics from the current control point to the following one
Label Label (for example, an SQL request)

Example:

FULL TIME: 3.1977
Start time: 08/11/2005 17:48:20
Start memory: 0.132

# Time Memory Label
1 0.1786 4.521 -
2 4.521 0.002 SELECT name, value, category FROM xcart_config
3 0.0476 0.170 -
4 0.0244 0.002 SELECT count(*) FROM xcart_sessions_data WHERE sessid='edc4f4c374e3a562e8891e14e00d2afc'
5 0.0002 0.000 -
6 0.0008 0.002 DELETE FROM xcart_sessions_data WHERE expiry<'1123768101'
81 0.0013 0.015 -
82 0.0288 0.003 SELECT xcart_products.productid, xcart_products.product, xcart_products.productcode, xcart_products.avail, MIN(xcart_pricing.price) AS price, xcart_product_features.fclassid, IF(xcart_product_features.fclassid IS NULL...
83 0.0003 -0.026 -
84 0.0719 0.001 SELECT name, value FROM xcart_languages WHERE code = 'US' AND name IN ('lbl_sku','lbl_product','lbl_price','lbl_default')
85 0.4190 0.271 -

SQL time: 2.4501 (76.62%)
PHP time: 0.2571 (8.04%)
Smarty time: 0.4910 (15.35%)
Used memory: 6.415Mb