OWASP / Maturity-Models

Node application to help managing Maturity Models like the ones created by BSIMM and OpenSAMM
Apache License 2.0
187 stars 51 forks source link

Performance issue on multiple Data_Project methods #167

Closed DinisCruz closed 8 years ago

DinisCruz commented 8 years ago

This is causing a number of delays on tests when there are 150+ projects

Will become an issue as more projects are added, and it is making some tests unstable in wallaby (which seems to have more of a problem vs mocha)

Here is the test that replicates the problem

  require 'fluentnode'

  it.only 'Performance issue on multiple Data_Project methods #167', ->
    start = Date.now()

    using new Data_Project(), ->
      @.projects()._keys().size().assert_Is 2                          # there are 2 projects
      (Date.now() - start).assert_Smaller_Than 3                       # @.projects() is sub 3 ms

      for i in [1..10]                                                 # call @.project_Files 10 times
        @.project_Files('bsimm')[0].size().assert_In_Between 140,160   # there are about 150 projects
      (Date.now() - start).assert_In_Between 250,500                   # 10x @.project_Files() takes more than 250ms
                                                                       #   this becomes a problem for actions like
                                                                       #   calculate scores which will call @.project_Files
                                                                       #   once per project (i.e. 150+ times)```

Note how @wallabyjs is 3x slower than mocha

image

Similar problem has occurred in the past (see #108 and #72)

DinisCruz commented 8 years ago

Done (after refactoring of #168 which uses a in memory cache now)

Here is the performance gain (note that we are now testing 400x calls)

image