<html>
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    On 11-08-11 11:23 AM, Ivan Nečas wrote:
    <blockquote cite="mid:4E43E5F3.3020400@redhat.com" type="cite">On
      08/11/2011 02:55 AM, Mike McCune wrote:
      <br>
      <blockquote type="cite">On 08/04/2011 03:53 AM, Lukas Zapletal
        wrote:
        <br>
        <blockquote type="cite">Hello,
          <br>
          <br>
          saw this today
          <br>
          <br>
          <a class="moz-txt-link-freetext" href="http://bit.ly/rb0UWM">http://bit.ly/rb0UWM</a>
          <br>
          <br>
          and here are some points to make our unit tests faster:
          <br>
          <br>
          1) "rspec spec" instead of "rails spec"
          <br>
          <br>
          On my laptop this improves it from 0m51.863s to 0m32.116s.
          <br>
          <br>
          2) sqlite in memory mode
          <br>
          <br>
          This is actually slower on my laptop (about 2 seconds).
          <br>
          <br>
          3) Since we dont have developer/integration tests (no real
          logins - we
          <br>
          just mock User object) there is no room for improvement
          regarding to the
          <br>
          authentication process.
          <br>
          <br>
          4) Did not test Spork server.
          <br>
          <br>
          Outcome: run "rspec test" instead of "rails spec" and you will
          be
          <br>
          faster. Please note:
          <br>
          <br>
          Top 10 slowest examples (please fix):
          <br>
          Â Â Â  SystemsController viewing systems and requesting
          individual data
          <br>
          should show packages
          <br>
          Â Â Â Â Â  1 seconds
          ./spec/controllers/systems_controller_spec.rb:84
          <br>
          Â Â Â  SystemsController viewing systems should throw an
          exception when the
          <br>
          search parameters are invalid
          <br>
          Â Â Â Â Â  1 seconds
          ./spec/controllers/systems_controller_spec.rb:60
          <br>
          Â Â Â  SystemsController viewing systems and requesting
          individual data
          <br>
          should show systems by env
          <br>
          Â Â Â Â Â  0.86844 seconds
          ./spec/controllers/systems_controller_spec.rb:90
          <br>
          Â Â Â  SystemsController viewing systems should show the
          system 2 pane list
          <br>
          Â Â Â Â Â  0.83007 seconds
          ./spec/controllers/systems_controller_spec.rb:44
          <br>
          Â Â Â  SystemsController viewing systems should return a
          portion of systems
          <br>
          Â Â Â Â Â  0.82123 seconds
          ./spec/controllers/systems_controller_spec.rb:52
          <br>
          Â Â Â  SystemsController viewing systems and requesting
          individual data
          <br>
          should show subscriptions
          <br>
          Â Â Â Â Â  0.81525 seconds
          ./spec/controllers/systems_controller_spec.rb:78
          <br>
          Â Â Â  SystemsController viewing systems and requesting
          individual data it
          <br>
          should show facts
          <br>
          Â Â Â Â Â  0.79887 seconds
          ./spec/controllers/systems_controller_spec.rb:72
          <br>
          Â Â Â  RolesController viewing roles should return a portion
          of roles
          <br>
          Â Â Â Â Â  0.79685 seconds
          ./spec/controllers/roles_controller_spec.rb:119
          <br>
          Â Â Â  RolesController viewing roles should show the role 2
          pane list
          <br>
          Â Â Â Â Â  0.78308 seconds
          ./spec/controllers/roles_controller_spec.rb:110
          <br>
          Â Â Â  NoticesController viewing notices should show all
          unread notices for
          <br>
          a user
          <br>
          Â Â Â Â Â  0.50836 seconds
          ./spec/controllers/notices_controller_spec.rb:46
          <br>
          <br>
        </blockquote>
        <br>
        The startup time is a dog:
        <br>
        <br>
        ## One test:
        <br>
        <br>
        $ time rake spec SPEC=spec/models/changeset_spec.rb
        <br>
        /usr/bin/ruby -S bundle exec rspec spec/models/changeset_spec.rb
        <br>
        ................
        <br>
        <br>
        Finished in 1.81 seconds
        <br>
        16 examples, 0 failures
        <br>
        <br>
        real    0m35.603s
        <br>
        user    0m20.948s
        <br>
        sys    0m5.392s
        <br>
        <br>
        ## All tests:
        <br>
        <br>
        $ time rake spec
        <br>
        [....]
        <br>
        Finished in 37.27 seconds
        <br>
        594 examples, 0 failures, 20 pending
        <br>
        <br>
        real    1m11.193s
        <br>
        user    0m54.833s
        <br>
        sys    0m8.033s
        <br>
        <br>
        So almost ~30 seconds of wall time is just getting the env up
        and going ..
        <br>
        <br>
      </blockquote>
      Hi,
      <br>
      <br>
      Using sport should cut the time off.
      <br>
      <br>
      Without spork:
      <br>
      <br>
      time rspec spec/models/changeset_spec.rb
      <br>
      <br>
      Finished in 0.90513 seconds
      <br>
      16 examples, 0 failures
      <br>
      <br>
      real  0m5.784s
      <br>
      user  0m4.983s
      <br>
      sys  0m0.753s
      <br>
      <br>
      <br>
      With spork:
      <br>
      <br>
      time rspec spec/models/changeset_spec.rb  --drb
      <br>
      <br>
      Finished in 1.04 seconds
      <br>
      16 examples, 0 failures
      <br>
      <br>
      real  0m1.526s
      <br>
      user  0m0.098s
      <br>
      sys  0m0.017s
      <br>
      <br>
      To be really useful, it needs to change set config.cache_classes =
      false in config/environments/test.rb. Unfortunately because of
      this, some tests fail, because this option causes lazy loading.
      <br>
      <br>
      It makes faster the start-up time, so it has no so huge impact on
      the whole test suite, but when you run one test frequently, it is
      a significant change.
      <br>
      <br>
      Ivan
      <br>
      <br>
    </blockquote>
    <font face="Arial">another option is to try using autotest - it will
      automatically run tests after it detects changes. I haven't tried
      it yet however.<br>
      -d<br>
    </font>
  </body>
</html>