ruby-prof for SerpApi's Search#parse!

PHOTO EMBED

Tue Feb 09 2021 09:46:46 GMT+0000 (Coordinated Universal Time)

Saved by @ilyazub #ruby #webscraping #serpapi

# tmp/profiler.rb

require "ruby-prof"

profile = RubyProf.profile do
  search_params = { engine: "google", q: "roller blades", location: "Austin, United States", google_domain: "google.com", hl: "en", gl: "us", num: "500", device: "desktop", tbm: "shop", tbs: "p_ord:rv", file_path: "tmp/roller-blades.html" }

  Search.new(search_params).parse!
end

printer = RubyProf::FlatPrinter.new(profile)
printer.print($stdout, min_percent: 2)
content_copyCOPY

https://medium.com/serpapi/how-we-sped-up-data-extraction-from-html-from-3s-to-800ms-or-how-to-profile-and-optimize-ruby-3390d69bce91