Skip to content

Instantly share code, notes, and snippets.

View abrandoned's full-sized avatar

Brandon Dewitt abrandoned

  • MoneyDesktop
  • Provo, UT
View GitHub Profile

Keybase proof

I hereby claim:

  • I am abrandoned on github.
  • I am abrandoned (https://keybase.io/abrandoned) on keybase.
  • I have a public key ASDxXi04uTExCvJyh0yj4-QmG5XN-zDhBKPtov1yiZ3v9Ao

To claim this, I am signing this object:

@abrandoned
abrandoned / gist:044cf200037ff7885572
Created February 1, 2016 02:31
Varint Encoding vs cached varint
[7] pry(Protobuf::Field::VarintField)> Benchmark.measure do
[7] pry(Protobuf::Field::VarintField)* 100_000.times do
[7] pry(Protobuf::Field::VarintField)* encode(512)
[7] pry(Protobuf::Field::VarintField)* end
[7] pry(Protobuf::Field::VarintField)* end
=> #<Benchmark::Tms:0x7813cb11
@cstime=0.0,
@cutime=0.0,
@label="",
@real=0.04975465498864651,
@abrandoned
abrandoned / jit log
Created August 14, 2013 23:55
jit log for jruby_802
*** Dumping jruby_802.setPosition ***
L0
ALOAD 0
LDC "jruby_802.rb"
ILOAD 1
INVOKEVIRTUAL org/jruby/runtime/ThreadContext.setFileAndLine (Ljava/lang/String;I)V
RETURN
*** Dumping jruby_802.__file__ ***
L0
ALOAD 0
@abrandoned
abrandoned / gist:5873269
Created June 27, 2013 01:24
flat/compact/uniq
1.9.3p374 :001 > require 'benchmark'
=> true
1.9.3p374 :002 > Benchmark.bm(7) do |bm|
1.9.3p374 :003 > bm.report("flatten") { 1_000_000.times { [1, 2, 3, nil, nil, nil, 3, 2, 1].flatten }}
1.9.3p374 :004?> bm.report("flatten!") { 1_000_000.times { [1, 2, 3, nil, nil, nil, 3, 2, 1].flatten! }}
1.9.3p374 :005?> bm.report("compact") { 1_000_000.times { [1, 2, 3, nil, nil, nil, 3, 2, 1].compact }}
1.9.3p374 :006?> bm.report("compact!") { 1_000_000.times { [1, 2, 3, nil, nil, nil, 3, 2, 1].compact! }}
1.9.3p374 :007?> bm.report("uniq") { 1_000_000.times { [1, 2, 3, nil, nil, nil, 3, 2, 1].uniq }}
1.9.3p374 :008?> bm.report("uniq!") { 1_000_000.times { [1, 2, 3, nil, nil, nil, 3, 2, 1].uniq! }}
1.9.3p374 :009?> end
@abrandoned
abrandoned / gist:1679523
Created January 25, 2012 23:06
httparrot config
module HTTParrot
class Config
@config = OpenStruct.new
def self.configure
yield self
end
def self.config
@config.instance_variable_get(:@table)