Skip to content

Instantly share code, notes, and snippets.

View luke-gru's full-sized avatar

Luke Gruber luke-gru

  • Montreal, Quebec
View GitHub Profile
@luke-gru
luke-gru / json_parse.rb
Created January 29, 2023 14:44
JSON parse tight loop
require 'json'
require 'benchmark'
RACTORS = ARGV.first == "ractor"
J = { rand => rand }.to_json
Ractor.make_shareable(J)
iterations = 1_000_000
Benchmark.bmbm do |x|
x.report("json parse#{RACTORS ? ' (ractors)' : ''}") {
@luke-gru
luke-gru / rails_render_benchmark_code_and_templates
Created June 27, 2014 02:53
Rails render benchmark code + templates
# test/template/benchmark/render_erb_test.rb
# encoding: utf-8
require 'abstract_unit'
require 'controller/fake_models'
require 'benchmark/ips'
class TestController < ActionController::Base
end
class RenderErbBenchmarks < ActiveSupport::TestCase
@luke-gru
luke-gru / rails_render_benchmark_without_change_rubyprof
Last active August 29, 2015 14:03
ruby 1.9.3 ERB rendering benchmark without change + rubyprof top 10 highest self time methods
(1.9.3)luke@luke-K52F:~/Desktop/code/rails/actionview$ ruby -Itest test/template/benchmark/render_erb_test.rb
Run options: --seed 48936
# Running:
Calculating -------------------------------------
small erb template 136 i/100ms
-------------------------------------------------
small erb template 1479.1 (±8.1%) i/s - 7344 in 5.007999s
.Calculating -------------------------------------
@luke-gru
luke-gru / rails_render_benchmark_with_change_rubyprof
Last active August 29, 2015 14:03
ruby 1.9.3 ERB rendering benchmark with change + rubyprof top 10 highest self time methods
(1.9.3)luke@luke-K52F:~/Desktop/code/rails/actionview$ ruby -Itest test/template/benchmark/render_erb_test.rb
Run options: --seed 33848
# Running:
Calculating -------------------------------------
small erb template 178 i/100ms
-------------------------------------------------
small erb template 1974.9 (±9.0%) i/s - 9790 in 5.009835s
.Calculating -------------------------------------
@luke-gru
luke-gru / rails_render_benchmark_without_change
Last active August 29, 2015 14:03
ruby 1.9.3 ERB rendering benchmark without change
Run options: --seed 49067
# Running:
Calculating -------------------------------------
small erb template 710 i/100ms
-------------------------------------------------
small erb template 8263.7 (±21.2%) i/s - 39760 in 5.027179s
.Calculating -------------------------------------
small erb template with 1 partial
@luke-gru
luke-gru / rails_render_benchmark_with_change
Last active August 29, 2015 14:03
ruby 1.9.3 ERB rendering benchmark with change
(1.9.3)luke@luke-K52F:~/Desktop/code/rails/actionview$ ruby -Itest test/template/benchmark/render_erb_test.rb
Run options: --seed 49022
# Running:
Calculating -------------------------------------
small erb template 761 i/100ms
-------------------------------------------------
small erb template 10220.5 (±21.5%) i/s - 48704 in 5.003189s
.Calculating -------------------------------------
@luke-gru
luke-gru / gist:5716783
Created June 5, 2013 19:53
test what email looks like in Rails
class Order
def send_order_email
OrderMailer.send_email(self).deliver
end
def test_order_email
body = send_order_email.body.to_s
File.open(File.join(Rails.root, 'public', 'email_test.html'), 'w') do |f|
f.puts body
end
<div class="span3 menu-side-bar">
<div id="menu" >
<ul class="niveau1">
<li id="selection-categorie">
<p>Selectionnez une catégorie</p>
</li>
<% cats = Category.roots.all %>
<% depth = 0 %>
<% while cat = cats.shift %>
<%# <li> with submenu %>
env:
app: /home/luke/workspace/traffic
paths:
java: /usr/lib/jvm/java-6-sun-1.6.0.26/bin
android: /home/luke/android-sdks
android-ndk: /home/luke/android-ndk-r7
cabwiz: C:/Program Files/Windows Mobile 6 SDK/Tools/CabWiz
4.6:
jde: C:/Program Files/Research In Motion/BlackBerry JDE 4.6.0
mds: C:/Program Files/Research In Motion/BlackBerry JDE 4.6.0/MDS
env:
app: /home/luke/workspace/traffic
paths:
java: /usr/lib/jvm/java-6-sun-1.6.0.26/bin
android: /home/luke/android-sdks
android-ndk: /home/luke/android-ndk-r7
cabwiz: C:/Program Files/Windows Mobile 6 SDK/Tools/CabWiz
4.6:
jde: C:/Program Files/Research In Motion/BlackBerry JDE 4.6.0
mds: C:/Program Files/Research In Motion/BlackBerry JDE 4.6.0/MDS