Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-org code #449

Closed
wants to merge 3 commits into from
Closed

Re-org code #449

wants to merge 3 commits into from

Conversation

jsumners
Copy link
Member

@jsumners jsumners commented Aug 28, 2023

The impetus for this PR was me starting to work on a suggestion PR for #445. When I got into the code, I decided that we have long ago outgrown the structure of the codebase as I created it when splitting this module out of the core Pino module. Basically, it has grown in a difficult to navigate mess with everything crammed into a few large files.

I have more that I intend to do, but I think this PR has become large enough as it is. So I'm halting my work until we make a decision on this (🤞 that means it's merged).


This PR is not yet complete as of commit 065fc99. I just want to put it up to show the following:

As of that commit, the "utils" file has been split out into a directory, lib/utils/. This directory has one file per utility function and a corresponding test file for each utility function file. It also updates the tap configuration to include a coverage map. The result is that we are not actually covering at 100% as we assumed:

Coverage Report
❯ tap
Suites:   ​27 passed​, ​27 of 27 completed​
Asserts:  ​​​453 passed​, ​of 453​
ERROR: Coverage for lines (95.48%) does not meet global threshold (100%)
ERROR: Coverage for functions (93.75%) does not meet global threshold (100%)
ERROR: Coverage for branches (85.77%) does not meet global threshold (100%)
ERROR: Coverage for statements (93.29%) does not meet global threshold (100%)
-------------------------------------|---------|----------|---------|---------|-------------------
File                                 | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s 
-------------------------------------|---------|----------|---------|---------|-------------------
All files                            |   93.29 |    85.77 |   93.75 |   95.48 |                   
 lib                                 |     100 |    90.62 |     100 |     100 |                   
  colors.js                          |     100 |    90.62 |     100 |     100 | 47-48,59          
 lib/utils                           |   92.19 |    84.97 |   91.66 |   94.71 |                   
  build-safe-sonic-boom.js           |   93.75 |    66.66 |   66.66 |   93.75 | 21                
  create-date.js                     |     100 |      100 |     100 |     100 |                   
  delete-log-property.js             |     100 |       80 |     100 |     100 | 24                
  filter-log.js                      |     100 |      100 |     100 |     100 |                   
  format-time.js                     |   95.23 |    93.33 |     100 |   95.23 | 45                
  get-property-value.js              |     100 |      100 |     100 |     100 |                   
  handle-custom-levels-names-opts.js |    92.3 |    71.42 |     100 |     100 | 18,24             
  handle-custom-levels-opts.js       |    92.3 |    71.42 |     100 |     100 | 18,24             
  interpret-conditionals.js          |     100 |      100 |     100 |     100 |                   
  is-object.js                       |     100 |      100 |     100 |     100 |                   
  is-valid-date.js                   |     100 |      100 |     100 |     100 |                   
  join-lines-with-indentation.js     |     100 |      100 |     100 |     100 |                   
  noop.js                            |     100 |      100 |     100 |     100 |                   
  prettify-error-log.js              |   38.46 |    46.15 |   33.33 |   45.45 | 48-69             
  prettify-error.js                  |     100 |      100 |     100 |     100 |                   
  prettify-level.js                  |     100 |    83.33 |     100 |     100 | 39                
  prettify-message.js                |     100 |      100 |     100 |     100 |                   
  prettify-metadata.js               |     100 |     87.5 |     100 |     100 | 28,32,43,50       
  prettify-object.js                 |   94.28 |    73.33 |     100 |     100 | 52,60,74-105      
  prettify-time.js                   |     100 |    91.66 |     100 |     100 | 45                
  split-property-key.js              |     100 |      100 |     100 |     100 |                   
-------------------------------------|---------|----------|---------|---------|-------------------

Okay, so that's not quite true. The difference is that some of the coverage comes through the factory function tests. With the restructure we have 1:1 test to code and we can see the gaps. it is my opinion that we should be able to recognize that file Y covers code X. Prior to this PR, one has to dig through a lot of code to find where something might be covering the code in question. As an example, in order to properly cover a case in handle-custom-levels-opts and handle-custom-levels-names-opts I had to read back through the git blame and learn what code was added to cover an odd branch.


After rebasing this on #451, I get numbers like this for the changes in this PR:

basicLog*10000: 759.376ms
objectLog*10000: 619.476ms
coloredLog*10000: 731.759ms
customPrettifiers*10000: 724.363ms
logWithErrorObject*10000: 561.199ms
logRemappedMsgErrKeys*10000: 556.772ms
messageFormatString*10000: 924.174ms
basicLog*10000: 726.8ms
objectLog*10000: 609.106ms
coloredLog*10000: 725.651ms
customPrettifiers*10000: 722.982ms
logWithErrorObject*10000: 562.306ms
logRemappedMsgErrKeys*10000: 561.282ms
messageFormatString*10000: 968.223ms

So, roughly no change in performance by splitting the functions out into their own files/scopes.

@jsumners jsumners changed the title Re-org code and add docs Re-org code Aug 28, 2023
@jsumners jsumners marked this pull request as ready for review August 28, 2023 20:55
@jsumners jsumners requested a review from mcollina August 28, 2023 20:55
@jsumners jsumners mentioned this pull request Aug 30, 2023
@jsumners jsumners changed the base branch from master to basic-bench August 30, 2023 13:58
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rubberstamp lgtm

@jsumners jsumners deleted the branch basic-bench August 30, 2023 22:54
@jsumners jsumners closed this Aug 30, 2023
@jsumners
Copy link
Member Author

Uh, wtf github? Why have you closed this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants