# Using benchmark method

**URL:** <https://www.ruby-forum.com/t/using-benchmark-method/114590>\
**Category:** Rails\
**Created:** [September 17, 2007, 1:30am UTC](https://www.ruby-forum.com/t/using-benchmark-method/114590 "2007-09-17T01:30:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ldk2005](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/d9b06d/32.png) [@ldk2005](https://www.ruby-forum.com/u/ldk2005)\
**Post date:** [September 17, 2007, 1:30am UTC](https://www.ruby-forum.com/t/using-benchmark-method/114590/1 "2007-09-17T01:30:20Z")

</div>

Hi,

I’m trying to use the benchmark method (from Module  
ActionController::Benchmarking::ClassMethods).

But I get a “undefined method benchmark.”

I’m trying to use it from inside a method in a subclass of  
ActionController::Caching::Sweeper

Ideas much appreciated.

Thanks,

Larry

```auto

class CacheSweeper < ActionController::Caching::Sweeper
  # sweeps the page cache for the conference site pages

  observe Conference

  def after_save(conference)
    dir = "#{page_cache_directory}/cs/conference.id"
    benchmark "Expired directory: #{dir}" do
      FileUtils.remove_dir(dir) # pg 231 -- Ruby Cookbook
    end
  end
end
```
