Skip to content

Instantly share code, notes, and snippets.

View goncalossilva's full-sized avatar
🚀

Gonçalo Silva goncalossilva

🚀
View GitHub Profile
GCdata
1.9.2: http://github.com/wycats/ruby-prof/blob/master/patches/gcdata/ruby192gc.patch
1.9.3: http://github.com/wycats/ruby-prof/blob/master/patches/gcdata/ruby193gc.patch
Zero-copy context switching
1.8.6: http://timetobleed.com/files/186-hs.patch
1.8.7: http://timetobleed.com/files/187-hs.patch
MBARI
1.6.8:http://sites.google.com/site/brentsrubypatches/Home/ruby-1.6.8-mbari8B.patch?attredirects=0&d=1
Test applications live under ci/benchmark/* (and ignored with .gitignore)
1. rails generate benchmarking_data
2. rails generate benchmarking_routes (depends on 1. for PUT/DELETE)
3. rails generate benchmarking_ci (runs 1. and 2.)
4. rake benchmark
1.
- Checks if test/fixtures/rails_benchmarking_ci/data/* was not already automatically generated
- Generates fake data automatically and stores it in test/fixtures/rails_benchmarking_ci/data/*
(05:59) gsilva ~/Projects/redmine[rails3] $ time rails generate dummy:all
successful initialize Rails application
create test/dummy/data
successful generate 20 records for 'workflow'
successful generate 10 records for 'project'
successful generate 20 records for 'version'
successful generate 10 records for 'setting'
successful generate 40 records for 'journal'
successful generate 10 records for 'project_custom_field'
successful generate 40 records for 'comment'
---
total_time: 0.43
threads:
78550710:
total_time: 0.43
methods:
Global#[No method]:
calls: 1
total_time: 0.43
self_time: 0.0
From 53f2f7aef15c89f60a6a75b2b55cd124600d0c23 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gon=C3=A7alo=20Silva?= <goncalossilva@gmail.com>
Date: Mon, 3 Jan 2011 18:51:57 +0000
Subject: [PATCH] use clock_gettime() instead of clock() when measuring process time under Linux
clock() limits it to centisecond precision on Linux
---
ext/ruby_prof/measure_process_time.h | 13 ++++++++++++-
1 files changed, 12 insertions(+), 1 deletions(-)
class Array
def trollface
puts <<-EOTF
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666
# wtf
Psych::ScalarScanner.new.tokenize("2011-02-24 11:17:06 -0800")
=> 2011-03-29 20:17:06 +0100
# this date format is important because of git
(19:43) goncalossilva ~/Desktop/rails[master] $ git show -s --pretty=format:"%ci" 13547c16d97b5f52db11d9f48704bbea20b54a4c
2011-02-24 11:17:06 -0800
rbx-head :037 > lb = Rubinius::Agent.loopback
=> #<Rubinius::Agent:0x1884 @decoder=#<BERT::Decode:0x1888 @in=#<IO:0x188c> @peeked=""> @io=#<IO:0x188c> @encoder=#<BERT::Encode:0x1894 @out=#<IO:0x188c>>>
rbx-head :038 > lb.get("system.memory.counter.bytes").last # this is memory
=> 45022024
rbx-head :040 > lb.get("system.memory.counter.objects").last # this is the amount of object allocations
=> 1367753
rbx-head :041 > lb.get("system.gc.full.count").last + lb.get("system.gc.young.count").last # this is the amount of gc runs
=> 13
rbx-head :042 > lb.get("system.gc.full.wallclock").last + lb.get("system.gc.young.wallclock").last # and the amount of time spent gcing
=> 217
From 5e048a2952661a975814b3f89c679c22f5b702ed Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gon=C3=A7alo=20Silva?= <goncalossilva@gmail.com>
Date: Thu, 24 Mar 2011 21:29:02 +0000
Subject: [PATCH] measure object allocations when rb_gc_malloc_allocations is available
---
ext/ruby_prof/measure_allocations.h | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/ext/ruby_prof/measure_allocations.h b/ext/ruby_prof/measure_allocations.h
@goncalossilva
goncalossilva / gist:1115856
Created July 30, 2011 18:58
Codebits talk proposals rank
require 'rubygems'
require 'json'
require 'net/http'
require 'statistics2'
# from http://www.evanmiller.org/how-not-to-sort-by-average-rating.html
def ci_lower_bound(pos, n, power)
return 0 if n == 0
z = Statistics2.pnormaldist(1-power/2)
phat = 1.0*pos/n