Skip to content
This repository has been archived by the owner on Mar 11, 2019. It is now read-only.

Commit

Permalink
Refatorado testes, Adicionado Cache na URL individual dos podcasts e …
Browse files Browse the repository at this point in the history
…atualizado Sweeper
  • Loading branch information
thiagopradi committed Sep 2, 2008
1 parent 4493e03 commit c422573
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 9 deletions.
3 changes: 2 additions & 1 deletion app/controllers/podcasts_controller.rb
Expand Up @@ -7,6 +7,7 @@ def method_missing(name, *args)
@podcast = Podcast.find_by_permalink(name.to_s)
if @podcast
render :action => "show", :podcast => @podcast
cache_page if ActionController::Base.perform_caching
else
render :action => "notfound"
end
Expand All @@ -18,7 +19,7 @@ def index
end

def show

end

def notfound
Expand Down
1 change: 1 addition & 0 deletions app/sweepers/podcast_sweeper.rb
Expand Up @@ -17,6 +17,7 @@ def after_destroy(podcast)
def expire_cache_for(record)
cache_dir = ActionController::Base.page_cache_directory
FileUtils.rm_r(Dir.glob("#{cache_dir}/index.html")) rescue Errno::ENOENT
FileUtils.rm_r(Dir.glob("#{cache_dir}/podcast/*.*")) rescue Errno::ENOENT
end
end

2 changes: 1 addition & 1 deletion app/views/podcasts/show.text
Expand Up @@ -17,4 +17,4 @@
<% end %>
</ul>

<%= @podcast.content %>
<%= @podcast.content %>
89 changes: 89 additions & 0 deletions log/httperf_benchmark.log.txt
@@ -0,0 +1,89 @@
## Benchmarking de cache, do Rails Podcast Brasil.
## Página Principal, sem cache!
httperf --client=0/1 --server=localhost --port=3000 --uri=/podcasts --send-buffer=4096 --recv-buffer=16384 --num-conns=5000 --num-calls=1
Maximum connect burst length: 1

Total: connections 5000 requests 5000 replies 5000 test-duration 96.744 s

Request rate: 51.7 req/s (19.3 ms/req)
Request size [B]: 68.0

Reply rate [replies/s]: min 43.0 avg 51.7 max 58.4 stddev 4.4 (19 samples)
Reply time [ms]: response 18.9 transfer 0.0
Reply size [B]: header 468.0 content 5312.0 footer 0.0 (total 5780.0)
Reply status: 1xx=0 2xx=5000 3xx=0 4xx=0 5xx=0

Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0

##
## Cacheamento da página principal
##

httperf --client=0/1 --server=localhost --port=3000 --uri=/podcasts --send-buffer=4096 --recv-buffer=16384 --num-conns=5000 --num-calls=1
Maximum connect burst length: 1

Total: connections 5000 requests 5000 replies 5000 test-duration 9.795 s

Request rate: 510.5 req/s (2.0 ms/req)
Request size [B]: 68.0

Reply rate [replies/s]: min 502.4 avg 502.4 max 502.4 stddev 0.0 (1 samples)
Reply time [ms]: response 1.8 transfer 0.0
Reply size [B]: header 197.0 content 5312.0 footer 0.0 (total 5509.0)
Reply status: 1xx=0 2xx=5000 3xx=0 4xx=0 5xx=0

Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0

##
## Página de cada podcast Individual, sem cache e sem refatoração!
##

httperf --client=0/1 --server=localhost --port=3000 --uri=/podcast/podcast-14-teste --send-buffer=4096 --recv-buffer=16384 --num-conns=1000 --num-calls=1
Maximum connect burst length: 1

Total: connections 1000 requests 1000 replies 1000 test-duration 20.995 s

Request rate: 47.6 req/s (21.0 ms/req)
Request size [B]: 84.0

Reply rate [replies/s]: min 45.4 avg 47.5 max 50.4 stddev 2.5 (4 samples)
Reply time [ms]: response 20.0 transfer 0.0
Reply size [B]: header 468.0 content 4714.0 footer 0.0 (total 5182.0)
Reply status: 1xx=0 2xx=1000 3xx=0 4xx=0 5xx=0

Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0

###
### Página de cada podcast Individual, refatorado!
###
httperf --client=0/1 --server=localhost --port=3000 --uri=/podcast/podcast-14-teste --send-buffer=4096 --recv-buffer=16384 --num-conns=1000 --num-calls=1
Maximum connect burst length: 1

Total: connections 1000 requests 1000 replies 1000 test-duration 16.439 s

Reply rate [replies/s]: min 59.4 avg 60.3 max 60.8 stddev 0.8 (3 samples)
Reply time [ms]: response 16.3 transfer 0.0
Reply size [B]: header 468.0 content 4714.0 footer 0.0 (total 5182.0)
Reply status: 1xx=0 2xx=1000 3xx=0 4xx=0 5xx=0

Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0

###
### Página de cada podcast, refatorado e com cache!
###
httperf --client=0/1 --server=localhost --port=3000 --uri=/podcast/podcast-14-teste --send-buffer=4096 --recv-buffer=16384 --num-conns=7000 --num-calls=1
Maximum connect burst length: 1

Total: connections 7000 requests 7000 replies 7000 test-duration 11.737 s

Reply rate [replies/s]: min 568.8 avg 592.9 max 617.0 stddev 34.1 (2 samples)
Reply time [ms]: response 1.6 transfer 0.0
Reply size [B]: header 197.0 content 4714.0 footer 0.0 (total 4911.0)
Reply status: 1xx=0 2xx=7000 3xx=0 4xx=0 5xx=0

Errors: total 0 client-timo 0 socket-timo 0 connrefused 0 connreset 0
Errors: fd-unavail 0 addrunavail 0 ftab-full 0 other 0
9 changes: 2 additions & 7 deletions test/functional/podcasts_controller_test.rb
Expand Up @@ -9,15 +9,10 @@ def test_index
get :index
assert_equal all_podcasts, assigns(:podcasts)
end
# Não necessário após refatorações
#
#def test_show
# get :show, :id => 1
#assert_equal 1, assigns(:podcast).id
#end

def test_method_missing_when_permalink_is_not_found
assert_raise(ActionController::UnknownAction) { get :not_found }
get "podcast12312432132131"
assert_template "notfound"
end

def test_method_missing_when_permalink_is_found
Expand Down

0 comments on commit c422573

Please sign in to comment.