Rails Performance Test

Filed under:rails — posted by admin on July 19, 2009 @ 2:46 pm
  • Install ruby-prof gem

  • gem install ruby-prof

  • Prepare fixtures test/fixtures/xxx for testing. Test one by one as the following:

  • ruby test/unit/xxx_test.rb

  • Edit test/performance/browsing_test.rb

  • require 'test_helper'
    require 'performance_test_help'

    # Profiling results for each test method are written to tmp/performance.
    class BrowsingTest < ActionController::PerformanceTest
    def test_homepage
    get '/'
    end
    end

  • Benchmarking

  • rake test:benchmark


    Started
    BrowsingTest#test_homepage (1062 ms warmup)
    process_time: 406 ms
    memory: 0.00 KB
    objects: 0
    gc_runs: 0
    gc_time: 0 ms
    .
    Finished in 10.501 seconds.

    5 tests, 0 assertions, 0 failures, 0 errors

  • Profiling

  • rake test:profile


    Started
    BrowsingTest#test_homepage (858 ms warmup)
    process_time: 655 ms
    memory: unsupported
    objects: unsupported
    .
    Finished in 32.845 seconds.

    3 tests, 0 assertions, 0 failures, 0 errors

zero comments so far »

Please won't you leave a comment, below? It'll put some text here!

Copy link for RSS feed for comments on this post or for TrackBack URI

Leave a comment

Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

(required)

(required)




image: detail of installation by Bronwyn Lace