Skip to content

Poor code coverage in the benchmarks #676

Closed

Description

@jdmarshall

I'm looking at #628 for my next trick, and of course the first thing I want to do is have some of the information from the horse's mouth instead of a partially incomplete express.js example.

cluster.js and pushGateway.js have particularly poor code coverage, which likely explains why metricAggregators.js is also low.

⚠ Benchmarks failed to perform better than the currently published version.
- Please determine if the performance changes are expected and acceptable.
---------------------------------|---------|----------|---------|---------|---------------------------------------------------
File                             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                                 
---------------------------------|---------|----------|---------|---------|---------------------------------------------------
All files                        |   46.54 |    22.47 |   42.65 |    47.3 |                                                   
 prom-client                     |   88.88 |      100 |       0 |   88.88 |                                                   
  index.js                       |   88.88 |      100 |       0 |   88.88 | 14-17                                             
 prom-client/benchmarks          |   97.59 |      100 |   97.43 |   97.53 |                                                   
  counter.js                     |     100 |      100 |     100 |     100 |                                                   
  gauge.js                       |     100 |      100 |     100 |     100 |                                                   
  histogram.js                   |     100 |      100 |     100 |     100 |                                                   
  index.js                       |   81.81 |      100 |       0 |   81.81 | 16-18                                             
  registry.js                    |     100 |      100 |     100 |     100 |                                                   
  summary.js                     |     100 |      100 |     100 |     100 |                                                   
 prom-client/benchmarks/utils    |     100 |      100 |     100 |     100 |                                                   
  labels.js                      |     100 |      100 |     100 |     100 |                                                   
 prom-client/lib                 |   45.03 |    30.98 |   36.61 |   46.46 |                                                   
  bucketGenerators.js            |    9.52 |        0 |       0 |   10.52 | 4-12,16-30                                        
  cluster.js                     |   12.35 |        0 |       0 |   13.58 | 17-19,32-208                                      
  counter.js                     |   50.87 |    39.47 |   44.44 |    53.7 | 26-27,45-46,50,53,82-96,111-135                   
  defaultMetrics.js              |   78.26 |    14.28 |       0 |   78.26 | 41-48                                             
  exemplar.js                    |    12.5 |        0 |       0 |    12.5 | 12-32                                             
  gauge.js                       |   35.08 |       25 |    37.5 |   37.03 | 32-34,68-152,157                                  
  histogram.js                   |    57.6 |    36.36 |   58.06 |   58.19 | 31,42-48,57-58,80-97,108-109,135-203,225,234,270  
  metric.js                      |   66.66 |    52.17 |      50 |   66.66 | 13,28,31,34,37,40,44,50,60                        
  metricAggregators.js           |   13.79 |        0 |    6.66 |   17.39 | 12-41,54-79                                       
  pushgateway.js                 |   10.16 |        0 |       0 |   10.16 | 11-133                                            
  registry.js                    |   70.29 |    48.21 |    62.5 |   70.29 | 22,58,62,78-79,95,112,139-144,157-174,183-210,247 
  summary.js                     |   40.54 |    35.71 |   33.33 |   41.09 | 26,30-31,51-73,84-155,166,195                     
  timeWindowQuantiles.js         |   60.71 |    66.66 |      60 |   60.71 | 21-27,38-39,56-62                                 
  util.js                        |    62.5 |    45.16 |      60 |   64.15 | 8-13,28,74-90,122,134-148                         
  validation.js                  |   91.66 |    33.33 |     100 |    90.9 | 20                                                
 prom-client/lib/metrics         |    32.5 |     2.53 |    2.56 |   32.91 |                                                   
  eventLoopLag.js                |      26 |        0 |       0 |      26 | 26-30,34-125                                      
  gc.js                          |      52 |    17.64 |       0 |      52 | 25-54                                             
  heapSizeAndUsed.js             |   30.43 |        0 |       0 |   30.43 | 11-44                                             
  heapSpacesSizeAndUsed.js       |   30.76 |        0 |      25 |   30.76 | 14-49                                             
  osMemoryHeap.js                |   42.85 |     7.69 |       0 |   42.85 | 10-24,31                                          
  osMemoryHeapLinux.js           |    25.8 |        0 |       0 |   26.66 | 13-29,34-70                                       
  processCpuTotal.js             |   22.58 |        0 |       0 |   22.58 | 11-75                                             
  processHandles.js              |   36.84 |        0 |       0 |   36.84 | 12-38                                             
  processMaxFileDescriptors.js   |   21.73 |        0 |       0 |    23.8 | 11-40                                             
  processOpenFileDescriptors.js  |      40 |        0 |       0 |      40 | 10-28                                             
  processRequests.js             |   38.88 |        0 |       0 |   38.88 | 11-37                                             
  processResources.js            |      25 |        0 |       0 |   26.08 | 11-52                                             
  processStartTime.js            |      50 |        0 |       0 |      50 | 9-20                                              
  version.js                     |   54.54 |        0 |       0 |   54.54 | 10-22                                             
 prom-client/lib/metrics/helpers |   11.11 |        0 |       0 |   11.76 |                                                   
  processMetricsHelpers.js       |    7.14 |        0 |       0 |    7.69 | 4-25                                              
  safeMemoryUsage.js             |      25 |      100 |       0 |      25 | 5-8                                               
---------------------------------|---------|----------|---------|---------|---------------------------------------------------

Activity

  1. jdmarshall commented on Jul 3, 2025

    @jdmarshall
    ContributorAuthor

    And it turns out part of this is because neither benchmark nor benchmark-regression properly support async tests. Wonderful.

    bestiejs/benchmark.js#176

  2. jdmarshall commented on Jul 3, 2025

    @jdmarshall
    ContributorAuthor

    And we cannot use this convoluted solution because benchmark-regression doesn't work that way:

    bestiejs/benchmark.js#176 (comment)

                    const bench = new benchmark.Benchmark(name, () => fn(testModule.module, ctx));
    
  3. jdmarshall commented on Jul 5, 2025

    @jdmarshall
    ContributorAuthor

    #680:

    ---------------------------------|---------|----------|---------|---------|--------------------------------------------------
    File                             | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s                                
    ---------------------------------|---------|----------|---------|---------|--------------------------------------------------
    All files                        |    51.3 |    27.01 |   48.78 |   52.04 |                                                  
     prom-client                     |   88.88 |      100 |       0 |   88.88 |                                                  
      index.js                       |   88.88 |      100 |       0 |   88.88 | 14-17                                            
     prom-client/benchmarks          |   95.27 |      100 |      94 |   95.12 |                                                  
      cluster.js                     |     100 |      100 |     100 |     100 |                                                  
      counter.js                     |     100 |      100 |     100 |     100 |                                                  
      gauge.js                       |     100 |      100 |     100 |     100 |                                                  
      histogram.js                   |     100 |      100 |     100 |     100 |                                                  
      index.js                       |   80.64 |      100 |      50 |   80.64 | 28,35,38,60-63                                   
      registry.js                    |     100 |      100 |     100 |     100 |                                                  
      summary.js                     |     100 |      100 |     100 |     100 |                                                  
     prom-client/benchmarks/utils    |     100 |      100 |     100 |     100 |                                                  
      labels.js                      |     100 |      100 |     100 |     100 |                                                  
     prom-client/lib                 |   50.45 |    37.24 |   43.95 |   51.97 |                                                  
      bucketGenerators.js            |    9.52 |        0 |       0 |   10.52 | 4-12,16-30                                       
      cluster.js                     |   29.21 |     9.37 |   17.39 |   32.09 | 17-19,32-88,123,130,149-208                      
      counter.js                     |   55.17 |     42.1 |   55.55 |   58.18 | 26-27,45-46,50,53,82-96,112-113,126-135          
      defaultMetrics.js              |   78.26 |    14.28 |       0 |   78.26 | 41-48                                            
      exemplar.js                    |    12.5 |        0 |       0 |    12.5 | 12-32                                            
      gauge.js                       |   35.08 |       25 |    37.5 |   37.03 | 32-34,68-152,157                                 
      histogram.js                   |    57.6 |    36.36 |   58.06 |   58.19 | 31,42-48,57-58,80-97,108-109,135-203,225,234,270 
      metric.js                      |   66.66 |    52.17 |      50 |   66.66 | 13,28,31,34,37,40,44,50,60                       
      metricAggregators.js           |   68.96 |    66.66 |   46.66 |    82.6 | 59-80                                            
      pushgateway.js                 |   10.16 |        0 |       0 |   10.16 | 11-133                                           
      registry.js                    |   76.47 |    72.22 |   70.83 |   76.47 | 22,78-79,110,137-142,154-171,186-207             
      summary.js                     |   40.54 |    35.71 |   33.33 |   41.09 | 26,30-31,51-73,84-155,166,195                    
      timeWindowQuantiles.js         |   60.71 |    66.66 |      60 |   60.71 | 21-27,38-39,56-62                                
      util.js                        |   67.34 |    51.85 |   66.66 |   68.75 | 8-13,28,76-92,123                                
      validation.js                  |   91.66 |    33.33 |     100 |    90.9 | 20                                               
     prom-client/lib/metrics         |    32.5 |     2.53 |    2.56 |   32.91 |                                                  
      eventLoopLag.js                |      26 |        0 |       0 |      26 | 26-30,34-125                                     
      gc.js                          |      52 |    17.64 |       0 |      52 | 25-54                                            
      heapSizeAndUsed.js             |   30.43 |        0 |       0 |   30.43 | 11-44                                            
      heapSpacesSizeAndUsed.js       |   30.76 |        0 |      25 |   30.76 | 14-49                                            
      osMemoryHeap.js                |   42.85 |     7.69 |       0 |   42.85 | 10-24,31                                         
      osMemoryHeapLinux.js           |    25.8 |        0 |       0 |   26.66 | 13-29,34-70                                      
      processCpuTotal.js             |   22.58 |        0 |       0 |   22.58 | 11-75                                            
      processHandles.js              |   36.84 |        0 |       0 |   36.84 | 12-38                                            
      processMaxFileDescriptors.js   |   21.73 |        0 |       0 |    23.8 | 11-40                                            
      processOpenFileDescriptors.js  |      40 |        0 |       0 |      40 | 10-28                                            
      processRequests.js             |   38.88 |        0 |       0 |   38.88 | 11-37                                            
      processResources.js            |      25 |        0 |       0 |   26.08 | 11-52                                            
      processStartTime.js            |      50 |        0 |       0 |      50 | 9-20                                             
      version.js                     |   54.54 |        0 |       0 |   54.54 | 10-22                                            
     prom-client/lib/metrics/helpers |   11.11 |        0 |       0 |   11.76 |                                                  
      processMetricsHelpers.js       |    7.14 |        0 |       0 |    7.69 | 4-25                                             
      safeMemoryUsage.js             |      25 |      100 |       0 |      25 | 5-8                                              
    ---------------------------------|---------|----------|---------|---------|--------------------------------------------------
    

    Not as much improvement as I had hoped, but something:

    All files                        |   46.54 |    22.47 |   42.65 |    47.3 |                                                   
    All files                        |    51.3 |    27.01 |   48.78 |   52.04 |
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions