File: bench_methods.rb

package info (click to toggle)
ruby-facets 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 9,824 kB
  • sloc: ruby: 25,483; xml: 90; makefile: 20
file content (17 lines) | stat: -rw-r--r-- 287 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

class ManyMethods

  puts "Generating methods..."

  (0..100000).each do |i|
    define_method( "_#{i}" ) { puts "Called method #{i}." }
  end

end

mm = ManyMethods.new

n1 = Time.now
mm._50000
n2 = Time.now
puts "Time to call a single method among 100000: #{(n2 - n1).to_f} seconds."