wp-cli / profile-command

Quickly identify what's slow with WordPress
MIT License
266 stars 29 forks source link

Total row missing when --format=csv is used #144

Closed wpbullet closed 6 years ago

wpbullet commented 6 years ago

I noticed today the wp profile hook --all --spotlight command is showing different output

wp profile hook --all --spotlight

Output

+-----------------------------------------------------------+-----------------------------------------------------------------+---------+------------+-------------+-------------+------------+--------------+--------------+---------------+
| function(){}                                              | /home/master/.wp-cli/packages/vendor/wp-cli/profile-command/inc | 0.0003s | 0s         | 0           | 50%         | 1          | 1            | 0s           | 0             |
|                                                           | /class-profiler.php:78                                          |         |            |             |             |            |              |              |               |
| wp_maybe_load_widgets()                                   | wp-includes/functions.php:3673                                  | 0.0145s | 0s         | 0           |             | 0          | 0            | 0s           | 0             |
| underDEV\AdvancedCronManager\Server\Processor->block_cron | advanced-cron-manager/inc/Server/Processor.php:30               | 0.0009s | 0.0006s    | 1           | 66.67%      | 2          | 1            | 0s           | 0             |
| _executions()                                             |                                                                 |         |            |             |             |            |              |              |               |
| wpcf7()                                                   | contact-form-7/settings.php:88                                  | 0.0121s | 0s         | 0           |             | 0          | 0            | 0s           | 0             |
| wppb_plugin_init()                                        | profile-builder-pro/index.php:28                                | 0.04s   | 0s         | 0           | 100%        | 30         | 0            | 0s           | 0             |
| RevSliderFront::createDBTables()                          | revslider/public/revslider-front.class.php:211                  | 0.0046s | 0.0032s    | 3           | 90.91%      | 10         | 1            | 0s           | 0             |
| SimpleLoginLog->update_db_check()                         | simple-login-log/simple-login-log.php:290                       | 0.0001s | 0s         | 0           | 66.67%      | 2          | 1            | 0s           | 0             |
| UpdraftPlus_Addons_Migrator_RemoteSend->plugins_loaded()  | updraftplus/addons/migrator.php:1482                            | 0.0005s | 0.0002s    | 1           | 66.67%      | 2          | 1            | 0s           | 0             |
| UpdraftPlus->plugins_loaded()                             | updraftplus/class-updraftplus.php:499                           | 0.0029s | 0.0002s    | 1           | 66.67%      | 2          | 1            | 0s           | 0             |
| WC_Min_Max_Quantities::get_instance()                     | woocommerce-min-max-quantities/woocommerce-min-max-quantities.p | 0.0022s | 0.0008s    | 4           | 66.67%      | 8          | 4            | 0s           | 0             |
|                                                           | hp:52                                                           |         |            |             |             |            |              |              |               |
| SV_WC_Framework_Bootstrap->load_framework_plugins()       | woocommerce-product-documents/lib/skyverge/woocommerce/class-sv | 0.0165s | 0s         | 0           |             | 0          | 0            | 0s           | 0             |
|                                                           | -wc-framework-bootstrap.php:112                                 |         |            |             |             |            |              |              |               |
| wpseo_load_textdomain()                                   | wordpress-seo-premium/wp-seo-main.php:234                       | 0.0111s | 0s         | 0           |             | 0          | 0            | 0s           | 0             |
| WpSecurityAuditLog->Load()                                | wp-security-audit-log/wp-security-audit-log.php:252             | 0.0249s | 0.0065s    | 9           |             | 0          | 0            | 0s           | 0             |
| wpseo_init()                                              | wordpress-seo-premium/wp-seo-main.php:252                       | 0.02s   | 0s         | 0           | 100%        | 32         | 0            | 0s           | 0             |
| wpseo_premium_init()                                      | wordpress-seo-premium/wp-seo-premium.php:96                     | 0.0103s | 0s         | 0           | 100%        | 2          | 0            | 0s           | 0             |
| WooCommerce->init()                                       | woocommerce/woocommerce.php:416                                 | 0.034s  | 0.0006s    | 2           | 84.62%      | 11         | 2            | 0s           | 0             |
| wp_widgets_init()                                         | wp-includes/widgets.php:1438                                    | 0.013s  | 0s         | 0           | 100%        | 125        | 0            | 0s           | 0             |
| acf->init()                                               | woocommerce-shipping-tracking/classes/acf/acf.php:203           | 0.032s  | 0s         | 0           |             | 0          | 0            | 0s           | 0             |
| WC_Post_types::register_taxonomies()                      | woocommerce/includes/class-wc-post-types.php:38                 | 0.0177s | 0s         | 0           | 100%        | 94         | 0            | 0s           | 0             |
| WC_Post_types::register_post_types()                      | woocommerce/includes/class-wc-post-types.php:244                | 0.0054s | 0.0007s    | 1           | 93.33%      | 14         | 1            | 0s           | 0             |
| Vc_Manager->init()                                        | js_composer/js_composer.php:244                                 | 0.0904s | 0.0057s    | 6           | 18.6%       | 16         | 70           | 0s           | 0             |
| jckWooDeliverySlots->initiate()                           | jck_woo_deliveryslots/jck_woo_deliveryslots.php:139             | 0.0035s | 0.0005s    | 1           | 87.5%       | 7          | 1            | 0s           | 0             |
| TI_WooCommerce_WishList_Extra_Fields::init()              | ti-woocommerce-wishlist-extra-fields/ti-woocommerce-wishlist-ex | 0.0013s | 0.0011s    | 1           |             | 0          | 0            | 0s           | 0             |
|                                                           | tra-fields.php:132                                              |         |            |             |             |            |              |              |               |
| WC_SA->init()                                             | woocommerce-status-actions/includes/class-wc-sa.php:239         | 0.0014s | 0.0009s    | 1           | 100%        | 3          | 0            | 0s           | 0             |
| WC_Emails::init_transactional_emails()                    | woocommerce/includes/class-wc-emails.php:68                     | 0.0009s | 0.0005s    | 1           |             | 0          | 0            | 0s           | 0             |
| WpSecurityAuditLog->Init()                                | wp-security-audit-log/wp-security-audit-log.php:175             | 0.0045s | 0.0023s    | 4           | 100%        | 2          | 0            | 0s           | 0             |
| wppb_manage_fields_submenu()                              | profile-builder-pro/admin/manage-fields.php:9                   | 0.006s  | 0s         | 0           | 88.24%      | 15         | 2            | 0s           | 0             |
| wppb_manage_ul_cpt()                                      | profile-builder-pro/modules/user-listing/userlisting.php:2208   | 0.0015s | 0s         | 0           | 80%         | 4          | 1            | 0s           | 0             |
| wppb_prepopulate_fields()                                 | profile-builder-pro/admin/manage-fields.php:199                 | 0.0005s | 0s         | 0           | 83.33%      | 5          | 1            | 0s           | 0             |
| WC_Tab_Manager->init()                                    | woocommerce-tab-manager/woocommerce-tab-manager.php:190         | 0.0136s | 0s         | 0           | 100%        | 4          | 0            | 0s           | 0             |
| Alg_WC_Checkout_Fees_Settings_Gateways->add_gateway_fees_ | checkout-fees-for-woocommerce/includes/admin/class-wc-checkout- | 0.0243s | 0.0038s    | 7           | 87.72%      | 50         | 7            | 0s           | 0             |
| settings_hook()                                           | fees-settings-gateways.php:42                                   |         |            |             |             |            |              |              |               |
| WP_Rewrite->flush_rules()                                 | wp-includes/class-wp-rewrite.php:1802                           | 0.0165s | 0.0066s    | 2           | 100%        | 200        | 0            | 0s           | 0             |
| pmxi_wp_loaded_99()                                       | wp-all-import-pro/actions/wp_loaded_99.php:3                    | 0.0007s | 0.0005s    | 1           |             | 0          | 0            | 0s           | 0             |
| WC_API->register_rest_routes()                            | woocommerce/includes/class-wc-api.php:210                       | 0.2086s | 0.0179s    | 35          | 93.67%      | 355        | 24           | 0s           | 0             |
| create_initial_rest_routes()                              | wp-includes/rest-api.php:182                                    | 0.0582s | 0s         | 0           | 76.42%      | 162        | 50           | 0s           | 0             |
| WC_SA->add_order_statuses()                               | woocommerce-status-actions/includes/class-wc-sa.php:337         | 0.0045s | 0.0032s    | 4           | 100%        | 2          | 0            | 0s           | 0             |
| _wp_admin_bar_init()                                      | wp-includes/admin-bar.php:23                                    | 0.0009s | 0.0003s    | 1           | 80%         | 4          | 1            | 0s           | 0             |
| Vc_Base->frontCss()                                       | js_composer/include/classes/core/class-vc-base.php:505          | 0.0017s | 0.0004s    | 1           | 66.67%      | 2          | 1            | 0s           | 0             |
| wp_enqueue_scripts()                                      | wp-includes/script-loader.php:1294                              | 0.0224s | 0.0025s    | 5           | 95.04%      | 115        | 6            | 0s           | 0             |
| wp_print_head_scripts()                                   | wp-includes/script-loader.php:1248                              | 0.0069s | 0.001s     | 2           | 90.7%       | 39         | 4            | 0s           | 0             |
| Vc_Base->bodyClass()                                      | js_composer/include/classes/core/class-vc-base.php:684          | 0.0005s | 0.0003s    | 1           | 66.67%      | 2          | 1            | 0s           | 0             |
| wptexturize()                                             | wp-includes/formatting.php:41                                   | 0.0272s | 0s         | 0           |             | 0          | 0            | 0s           | 0             |
| porto_add_custom_nav_fields()                             | porto/inc/menu/menu.php:16                                      | 0.0438s | 0s         | 0           | 100%        | 20         | 0            | 0s           | 0             |
+-----------------------------------------------------------+-----------------------------------------------------------------+---------+------------+-------------+-------------+------------+--------------+--------------+---------------+
| total (43)                                                |                                                                 | 0.8025s | 0.0603s    | 95          | 83.84%      | 1342       | 182          | 0s           | 0             |
+-----------------------------------------------------------+-----------------------------------------------------------------+---------+------------+-------------+-------------+------------+--------------+--------------+---------------+

With format=csv the bottom total column is gone

wp profile hook --all --spotlight --format=csv

Output

function(){},/home/master/.wp-cli/packages/vendor/wp-cli/profile-command/inc/class-profiler.php:78,0.00023913383483887,0,0,50%,1,1,0,0
"underDEV\AdvancedCronManager\Server\Processor->block_cron_executions()",advanced-cron-manager/inc/Server/Processor.php:30,0.00092601776123047,0.00055694580078125,1,66.67%,2,1,0,0
wpcf7(),contact-form-7/settings.php:88,0.010501861572266,0,0,,0,0,0,0
wppb_plugin_init(),profile-builder-pro/index.php:28,0.032809972763062,0,0,100%,30,0,0,0
RevSliderFront::createDBTables(),revslider/public/revslider-front.class.php:211,0.0057201385498047,0.0044279098510742,3,90.91%,10,1,0,0
SimpleLoginLog->update_db_check(),simple-login-log/simple-login-log.php:290,6.0081481933594E-5,0,0,66.67%,2,1,0,0
UpdraftPlus_Addons_Migrator_RemoteSend->plugins_loaded(),updraftplus/addons/migrator.php:1482,0.00049400329589844,0.00030612945556641,1,66.67%,2,1,0,0
UpdraftPlus->plugins_loaded(),updraftplus/class-updraftplus.php:499,0.0021529197692871,0.0002129077911377,1,66.67%,2,1,0,0
WC_Min_Max_Quantities::get_instance(),woocommerce-min-max-quantities/woocommerce-min-max-quantities.php:52,0.0018842220306396,0.00083327293395996,4,66.67%,8,4,0,0
WpSecurityAuditLog->Load(),wp-security-audit-log/wp-security-audit-log.php:252,0.019633054733276,0.0046637058258057,9,,0,0,0,0
wpseo_init(),wordpress-seo-premium/wp-seo-main.php:252,0.012759923934937,0,0,100%,32,0,0,0
WooCommerce->init(),woocommerce/woocommerce.php:416,0.044458866119385,0.00072503089904785,2,84.62%,11,2,0,0
wp_widgets_init(),wp-includes/widgets.php:1438,0.011989116668701,0,0,100%,125,0,0,0
acf->init(),woocommerce-shipping-tracking/classes/acf/acf.php:203,0.036365985870361,0,0,,0,0,0,0
WC_Post_types::register_taxonomies(),woocommerce/includes/class-wc-post-types.php:38,0.024302959442139,0,0,100%,94,0,0,0
WC_Post_types::register_post_types(),woocommerce/includes/class-wc-post-types.php:244,0.0076179504394531,0.00063204765319824,1,93.33%,14,1,0,0
Vc_Manager->init(),js_composer/js_composer.php:244,0.087106943130493,0.0060820579528809,6,18.6%,16,70,0,0
jckWooDeliverySlots->initiate(),jck_woo_deliveryslots/jck_woo_deliveryslots.php:139,0.0032269954681396,0.00032401084899902,1,87.5%,7,1,0,0
TI_WooCommerce_WishList_Extra_Fields::init(),ti-woocommerce-wishlist-extra-fields/ti-woocommerce-wishlist-extra-fields.php:132,0.001270055770874,0.0010240077972412,1,,0,0,0,0
WC_SA->init(),woocommerce-status-actions/includes/class-wc-sa.php:239,0.0013620853424072,0.00067400932312012,1,100%,3,0,0,0
WC_Emails::init_transactional_emails(),woocommerce/includes/class-wc-emails.php:68,0.00060105323791504,0.0003199577331543,1,,0,0,0,0
WpSecurityAuditLog->Init(),wp-security-audit-log/wp-security-audit-log.php:175,0.0040090084075928,0.0018119812011719,4,100%,2,0,0,0
wppb_manage_fields_submenu(),profile-builder-pro/admin/manage-fields.php:9,0.013191938400269,0,0,88.24%,15,2,0,0
wppb_manage_ul_cpt(),profile-builder-pro/modules/user-listing/userlisting.php:2208,0.005108118057251,0,0,80%,4,1,0,0
wppb_prepopulate_fields(),profile-builder-pro/admin/manage-fields.php:199,0.0012059211730957,0,0,83.33%,5,1,0,0
WC_Tab_Manager->init(),woocommerce-tab-manager/woocommerce-tab-manager.php:190,0.023850917816162,0,0,100%,4,0,0,0
Alg_WC_Checkout_Fees_Settings_Gateways->add_gateway_fees_settings_hook(),checkout-fees-for-woocommerce/includes/admin/class-wc-checkout-fees-settings-gateways.php:42,0.026709794998169,0.0035951137542725,7,87.72%,50,7,0,0
WP_Rewrite->flush_rules(),wp-includes/class-wp-rewrite.php:1802,0.026412963867188,0.0089561939239502,2,100%,200,0,0,0
pmxi_wp_loaded_99(),wp-all-import-pro/actions/wp_loaded_99.php:3,0.00083494186401367,0.0005490779876709,1,,0,0,0,0
WC_API->register_rest_routes(),woocommerce/includes/class-wc-api.php:210,0.18443202972412,0.016847133636475,35,93.67%,355,24,0,0
create_initial_rest_routes(),wp-includes/rest-api.php:182,0.050954103469849,0,0,76.42%,162,50,0,0
WC_SA->add_order_statuses(),woocommerce-status-actions/includes/class-wc-sa.php:337,0.0054359436035156,0.0040264129638672,4,100%,2,0,0,0
_wp_admin_bar_init(),wp-includes/admin-bar.php:23,0.00093197822570801,0.00032997131347656,1,80%,4,1,0,0
Vc_Base->frontCss(),js_composer/include/classes/core/class-vc-base.php:505,0.0020840167999268,0.00022602081298828,1,66.67%,2,1,0,0
wp_enqueue_scripts(),wp-includes/script-loader.php:1294,0.030303001403809,0.0024213790893555,5,95.04%,115,6,0,0
wp_print_head_scripts(),wp-includes/script-loader.php:1248,0.0088381767272949,0.001317024230957,2,90.7%,39,4,0,0
Vc_Base->bodyClass(),js_composer/include/classes/core/class-vc-base.php:684,0.00064182281494141,0.00025796890258789,1,66.67%,2,1,0,0
wptexturize(),wp-includes/formatting.php:41,0.036612987518311,0,0,,0,0,0,0
porto_add_custom_nav_fields(),porto/inc/menu/menu.php:16,0.043588161468506,0,0,100%,20,0,0,0
schlessera commented 6 years ago

That is intended behaviour. A CSV file does not know the concept of a "footer". It is meant to provide the data in a format that can be easily imported into spreadsheets or other tools, and the convention is that it either contains pure data, with 1 single, optional header line.

While there are CSV exporter that provide footer output for CSV files, this tends to create issues with a lot of common client tools, like MS Excel.

@danielbachhuber What's your take on this? Worth providing an optional argument to get the footer nevertheless?

danielbachhuber commented 6 years ago

A CSV file does not know the concept of a "footer". It is meant to provide the data in a format that can be easily imported into spreadsheets or other tools, and the convention is that it either contains pure data, with 1 single, optional header line.

Correct. This was the original design decision.

What's your take on this? Worth providing an optional argument to get the footer nevertheless?

It's fine to keep as-is.

@wpbullet If you pipe --format=table output to a file, you'll notice it ends up in tab-delimited format which you can parse just like CSV. Alternatively, you can parse the CSV output and calculate totals yourself.

wpbullet commented 6 years ago

Thanks for chiming in! The problem with using --format=table and something like column -t is that when you redirect to a file the footer column has a blank column which gets skipped! I have patched it by replacing the empty row with a - but it's far from pretty compared to if it was a csv.