-
-
Save jchris/117388 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'lib/yajl/http_stream' | |
require 'uri' | |
uri = URI.parse('http://jchrisa.net/toast/_changes') | |
Yajl::HttpStream.get(uri) do |hash| | |
# will take a few seconds, since the response is a single ~4MB JSON string | |
# if the response was a bunch of individual JSON strings, this would be fired | |
# for every string parsed off the stream, as they were parsed | |
puts hash.inspect | |
end | |
# For comparison | |
# ============== | |
# | |
# Download & Parse | |
# ---------------- | |
# time ruby test.rb | |
# real 0m8.685s | |
# user 0m1.228s | |
# sys 0m0.198s | |
# | |
# Download Only | |
# ------------- | |
# time curl http://jchrisa.net/toast/_all_docs_by_seq?include_docs=true > /dev/null | |
# real 0m8.587s | |
# user 0m0.067s | |
# sys 0m0.211s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment