Skip to content

Instantly share code, notes, and snippets.

@wapcaplet
Created March 15, 2012 22:14
Show Gist options
  • Save wapcaplet/2047316 to your computer and use it in GitHub Desktop.
Save wapcaplet/2047316 to your computer and use it in GitHub Desktop.
# ~/git/rsel $ ruby perf/simple-client.rb
# Loop time: 10.555982s
# Total time: 18.245965s
# ~/git/rsel $ ruby perf/simple-webdriver.rb
# Loop time: 18.025064s
# Total time: 24.989934s
# perf/simple-client.rb
require 'rubygems'
require 'time'
require 'selenium-client'
start = Time.now
browser = Selenium::Client::Driver.new(
:host => 'localhost',
:port => 4444,
:browser => '*firefox',
:url => 'http://localhost:8070')
browser.start_new_browser_session
loop_start = Time.now
100.times do
browser.open('/')
browser.click('link=About this site')
end
loop_time = Time.now - loop_start
browser.close_current_browser_session
total_time = Time.now - start
puts "Loop time: #{loop_time}s"
puts "Total time: #{total_time}s"
# perf/simple-webdriver.rb
require 'rubygems'
require 'time'
require 'selenium-webdriver'
start = Time.now
driver = Selenium::WebDriver.for :firefox
driver.navigate.to 'http://localhost:8070'
loop_start = Time.now
100.times do
link = driver.find_element(:link, 'About this site')
link.click
driver.navigate.back
end
loop_time = Time.now - loop_start
driver.quit
total_time = Time.now - start
puts "Loop time: #{loop_time}s"
puts "Total time: #{total_time}s"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment