Skip to content

Instantly share code, notes, and snippets.

View phiggins's full-sized avatar

pete higgins phiggins

View GitHub Profile
0a1,259
> Wed Aug 18 01:37:49 2010 NARUSE, Yui <naruse@ruby-lang.org>
>
> * regcomp.c: revert r26701; it introduces Bug #3681.
> [ruby-core:31677]
>
> Mon Aug 16 23:16:21 2010 Yusuke Endoh <mame@tsg.ne.jp>
>
> * NEWS: updated. a patch from Kazuhiro NISHIYAMA in [ruby-dev:42001].
>
require 'httparty'
class Webservice
CANDIDATE = <<XML
<Candidate xmlns="com.mysite/2010/10/10" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<FirstName>%s</FirstName>
<LastName>%s</LastName>
<Email>%s</Email>
<Gender>%s</Gender>
</Candidate>
# The many ways to use curb to do http requests.
#
# These all share code, but are different code paths.
require 'curb'
url = "http://www.example.com"
c = Curl::Easy.new(url)
c.url = url
@phiggins
phiggins / peach_bench.rb
Created October 21, 2010 01:00
Stupid benchmark of peach gem
require 'peach'
require 'benchmark'
def process(n)
sleep(1)
n**n
end
n = (ARGV.first || 60).to_i
@phiggins
phiggins / fake_itunes.xml
Created October 23, 2010 09:49
fake_itunes.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Tracks</key>
<dict>
<key>1</key>
<dict>
<key>Track ID</key><integer>1</integer>
<key>Name</key><string>Test song name 0</string>
@phiggins
phiggins / const_resolution.rb
Created November 16, 2010 23:57
Constant resolution across rubies
class TopLevel
module Constants
HelloWorld = "Hello, World!"
def self.hello_world
puts HelloWorld
end
end
end
TopLevel::Constants.class_eval do
class File
def self.buffer(path)
n = 0
size = File.size( path )
chunk = 2**16
File.open(path, "rb") do |f|
while n < size
n += chunk
yield f.sysread( chunk )
end
$ ruby -v
ruby 1.8.7 (2010-08-16 patchlevel 302) [x86_64-linux]
$ ruby -Ilib benchmarks/excon_vs.rb
[em-http-request, Excon, Excon (persistent), HTTParty, Net::HTTP, Net::HTTP (persistent), open-uri, RestClient, StreamlyFFI (persistent), Typhoeus]
+--------------------------+-----------+
| tach | total |
+--------------------------+-----------+
| Net::HTTP (persistent) | 2.288449 |
diff --git a/benchmarks/excon_vs.rb b/benchmarks/excon_vs.rb
index 5fa84e7..9f5e0cb 100644
--- a/benchmarks/excon_vs.rb
+++ b/benchmarks/excon_vs.rb
@@ -69,15 +69,6 @@ with_server do
}
end
- tach('Excon') do
- Excon.get(url).body
@phiggins
phiggins / excon benchmark
Created December 1, 2010 06:02
excon benchmark vs google
$ ruby benchmarks/excon_vs_google.rb
[em-http-request, HTTParty, Net::HTTP, Net::HTTP (persistent), open-uri, RestClient, StreamlyFFI (persistent), Typhoeus, Excon, Excon (persistent)]
+--------------------------+-----------+
| tach | total |
+--------------------------+-----------+
| Excon | 7.614298 |
+--------------------------+-----------+
| Typhoeus | 7.723362 |