cfengineers-net / cf-profile

Perl script for parsing output of verbose run for cf-agent and create execution tree with timings.
www.cfengineers.net
3 stars 4 forks source link

Top ten worst bundles are determined by lexicographic rather than numeric sorting #8

Open mikeweilgart opened 7 years ago

mikeweilgart commented 7 years ago
Top 10 worst, bundles:
    1.  5.78638s  : [redacted]
    2.  41.34302s  : [redaced]
    3.  4.71288s  : inventory_autorun

I expect this bug will not manifest unless there is at least one bundle that runs for over 10 seconds and at least one bundle that runs for 1-9 seconds. (In other words, there has to be a difference between lexicographic and numeric sort order for this issue to be visible.)

atsaloli commented 7 years ago

The fix for this issue is in https://github.com/cfengineers-net/cf-profile/pull/5 from over a year ago.

I'm afraid it looks like this project is no longer maintained.

@mikeweilgart : it's a 3 byte change and I've verified that it works, if you want to update your local copy.

To duplicate this issue, I put "/bin/sleep 4" in test and "/bin/sleep 11" in main:

Top 10 worst, bundles:
    1.  4.02403s  : test
    2.  15.05754s  : main
    3.  1.72461s  : cfe_internal_management
    4.  1.02561s  : cfe_internal_enterprise_main
    5.  0.64381s  : cfe_internal_enterprise_mission_portal
    6.  0.61825s  : cfe_internal_enterprise_mission_portal_apache
    7.  0.53955s  : cfe_internal_setup_knowledge
    8.  0.33595s  : cfe_internal_hub_maintain
    9.  0.20164s  : inventory_autorun
    10. 0.18930s  : cfe_internal_database_partitioning

I then changed stringwise comparison (cmp) to numeric (<=>) and it sorted correctly:

Top 10 worst, bundles:
    1.  15.04905s  : main
    2.  4.02275s  : test
    3.  1.71564s  : cfe_internal_management
    4.  0.99795s  : cfe_internal_enterprise_main
    5.  0.65410s  : cfe_internal_enterprise_mission_portal
    6.  0.62744s  : cfe_internal_enterprise_mission_portal_apache
    7.  0.52309s  : cfe_internal_setup_knowledge
    8.  0.32974s  : cfe_internal_hub_maintain
    9.  0.20210s  : inventory_autorun
    10. 0.19028s  : cfe_internal_database_partitioning