Skip to content

Instantly share code, notes, and snippets.

@mchung
mchung / poro-hashie-ostruct-benchmark.rb
Last active August 5, 2018 23:14 — forked from jgaskins/benchmark.rb
Hashie vs OpenStruct vs PORO performance
require 'hashie'
require 'ostruct'
require 'benchmark/ips'
class PORO
attr_reader :foo, :bar, :baz
def initialize attrs = {}
attrs.each do |attr, value|
instance_variable_set "@#{attr}", value
build_package_patched() {
# These three patches are included when RVM builds REE
cd source
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/tcmalloc.patch'
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/stdout-rouge-fix.patch'
wget 'https://github.com/wayneeseguin/rvm/raw/master/patches/ree/1.8.7/no_sslv2.diff'
patch -p1 < tcmalloc.patch
patch -p1 < stdout-rouge-fix.patch
patch -p1 < no_sslv2.diff
cd ..
require 'culerity'
$env_javascript_tag = ENV['CULERITY_JAVASCRIPT_TAG'] || '@javascript'
def set_jruby_env
rvm_jruby = ENV['CULERITY_RVM_JRUBY'] || 'jruby'
info = `rvm info #{rvm_jruby}`
gem_home = info =~ /GEM_HOME:\s?"([^"]*)"/ ? $1 : ''
gem_path = info =~ /GEM_PATH:\s?"([^"]*)"/ ? $1 : ''
my_ruby_home = info =~ /MY_RUBY_HOME:\s?"([^"]*)"/ ? $1 : ''
# Build an inverted index for a full-text search engine with Redis.
# Copyright (C) 2009 Salvatore Sanfilippo. Under the BSD License.
# USAGE:
#
# ruby invertedindex.rb add somedir/*.c
# ruby invertedindex.rb add somedir/*.txt
# ruby search your query string
require 'rubygems'
require 'redis'
require 'rubygems'
require 'sinatra'
require 'redis'
# To use, simply start your Redis server and boot this
# example app with:
# ruby example_note_keeping_app.rb
#
# Point your browser to http://localhost:4567 and enjoy!
#