Skip to content

Instantly share code, notes, and snippets.

@jarib
Created September 15, 2011 08:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jarib/1218797 to your computer and use it in GitHub Desktop.
Save jarib/1218797 to your computer and use it in GitHub Desktop.
require 'selenium-webdriver'
require "benchmark"
d = Selenium::WebDriver.for :firefox
d.get "data:text/html;content-type=utf-8,#{URI.encode DATA.read}"
e = d.find_element(:id => "q")
TESTS = 30
Benchmark.bmbm do |results|
results.report("clear + send_keys:") { TESTS.times {
e.clear
e.send_keys("hello world")
}
}
end
d.quit
__END__
<html>
<body>
<input id=q type=text>
</body>
</html>
$ gem install selenium-webdriver --version 2.5.0
Fetching: selenium-webdriver-2.5.0.gem (100%)
Successfully installed selenium-webdriver-2.5.0
1 gem installed
$ ruby bench.rb
Rehearsal ------------------------------------------------------
clear + send_keys: 0.120000 0.020000 0.140000 ( 2.455660)
--------------------------------------------- total: 0.140000sec
user system total real
clear + send_keys: 0.090000 0.020000 0.110000 ( 2.768515)
$ gem install selenium-webdriver --version 2.6.0
Fetching: selenium-webdriver-2.6.0.gem (100%)
Successfully installed selenium-webdriver-2.6.0
1 gem installed
$ ruby bench.rb
Rehearsal ------------------------------------------------------
clear + send_keys: 0.120000 0.020000 0.140000 ( 2.588306)
--------------------------------------------- total: 0.140000sec
user system total real
clear + send_keys: 0.100000 0.020000 0.120000 ( 2.699779)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment