Skip to content

Instantly share code, notes, and snippets.

(defn when-its-one []
(loop []
(if (= 1 (rand-int 2000))
1
[(println "foo")
(recur)])))
wget http://rubyforge.org/frs/download.php/70304/ruby-debug-base-0.10.3.2-java.gem
gem install ruby-debug-base-0.10.3.2-java.gem
gem install columnize
rm ruby-debug-base-0.10.3.2-java.gem
gem install ruby-debug --ignore-dependencies

Debugging ruby performance - Aman Gupta

C, Linux, networks, cpu, and memory usage

  • lsof -nPp <pid>
  • tcpdump
  • write the data to a file, load it up in wireshark
  • strace, trace systems calls and signals (jump into kernelspace)
  • SIGVTALRM, ruby 1.8 every 10msec to switch threads (green threads)
  • posix-spawn instead of fork-exec, check out posix-spawn gem
  • ltrace

– ltrace -c ruby foo.rb # summary mode

rcov 1.8 simple cov 1.9.x

SOLID Principles behind Rails 3.1

Single responsibility principle

  • One reason for a class to change
  • Makes Top-down comprehensibility (admittedly)
  • Better for maintainability,
ruby 1.8.7-p249
Finished in 121.97 seconds
1148 examples, 0 failures
rake spec 124.69s user 0.99s system 95% cpu 2:11.11 total
ree-1.8.7.2011.03
Finished in 60.47 seconds
1148 examples, 0 failures
rake spec 60.77s user 2.26s system 98% cpu 1:03.70 total
; Insert today's standup template into my org doc
(defun standup-org()
(interactive)
(insert "* Joe W. " (format-time-string "%Y-%m-%d") "\n")
(insert
(mapconcat 'identity '("** Yesterday" "** Today" "** Next" "") "\n-\n"))
~/src/rspec_minitest_benchmark (411d12h19m|master*)
$ time rspec rspec.rb && time ruby minispec.rb && time ruby minitest.rb
................
Finished in 0.00415 seconds
16 examples, 0 failures
rspec rspec.rb 0.22s user 0.05s system 98% cpu 0.278 total
Run options: --seed 24680
# Running tests:
"\e[A": history-search-backward
"\e[B": history-search-forward
$if Bash
Space: magic-space
$endif
"\M-o": "\C-p\C-a\M-f "
set completion-ignore-case on
set visible-stats on
set show-all-if-ambiguous on
"\M-s": menu-complete
@jwinter
jwinter / badfruit.gemspec
Created October 12, 2012 18:26
badfruit.gemspec
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = "badfruit"
s.version = "1.1.2"
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
s.authors = ["Brian Michel"]
s.date = "2012-04-21"
s.description = "Interface with the Rotten Tomatoes API"
class String
include Enumerable
def each(&block)
chars.each do |member|
block.call(member)
end
end
end