This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'time' | |
require 'benchmark' | |
class Thing | |
attr_accessor :timestamp | |
def initialize(timestamp) | |
@timestamp = timestamp | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### running this code: http://gist.github.com/234170 | |
### jruby trunk from last week | |
> jruby sorting.rb | |
Rehearsal --------------------------------------------- | |
merge: 1.070000 0.000000 1.070000 ( 1.070000) | |
nocopy: 0.730000 0.000000 0.730000 ( 0.730000) | |
------------------------------------ total: 1.800000sec | |
user system total real |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
本拠> bin/rbx ../sorting.rb | |
Rehearsal --------------------------------------------- | |
merge: 2.448515 0.000000 2.448515 ( 2.448516) | |
nocopy: 0.896591 0.000000 0.896591 ( 0.896639) | |
------------------------------------ total: 3.345106sec | |
user system total real | |
merge: 0.855341 0.000000 0.855341 ( 0.855353) | |
nocopy: 0.569976 0.000000 0.569976 ( 0.569993) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x,y,z = "X ", "Y ", "Z " | |
[x,y,z].each_with_index do |str, i| | |
str << str[0,1] | |
p str | |
redo if i == 1 | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
puts "ruby version: #{RUBY_VERSION}" | |
pass = 0 | |
proc do |@x| | |
pass += 1 | |
puts "proc pass number #{pass}" | |
@x = 3 if pass == 1 | |
puts "proc x is: #{@x}" | |
redo if pass != 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module IncludeMe;end | |
module BehindTheScenes;end | |
# Include IncludeMe in a module | |
module One | |
include IncludeMe | |
end | |
# Add an ancestor to IncludeMe | |
module IncludeMe |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Process: vm [69929] | |
Path: /Users/wilson/code/rbx/vm/vm | |
Identifier: vm | |
Version: ??? (???) | |
Code Type: X86-64 (Native) | |
Parent Process: zsh [37874] | |
Date/Time: 2009-11-22 04:23:08.915 -0500 | |
OS Version: Mac OS X 10.6.2 (10C540) | |
Report Version: 6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# shortcut method for opening a metaclass on the receiver | |
module Kernel;def m;class << self;self;end;end;end | |
Module.m # #<Class:Module>, metaclass of Module | |
Module.m.superclass # Class, because that is how Module is bootstrapped | |
Module.m.m # #<Class:#<Class:Module>>, metaclass of Module's metaclass | |
Module.m.superclass # #<Class:#<Class:Module>> | |
Module.m.m.superclass # #<Class:#<Class:Module>> | |
# Opening a metaclass on Module's metaclass changes its superclass to be the same as its metaclass's superclass!? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(gdb) rp already_meta->true_superclass(state) | |
#<Module(Class):0x101225df0> | |
name: :Module | |
superclass: #<Object(Class):0x101225d70> | |
constants: #<Rubinius::LookupTable:0x1014010a0> | |
method_table: #<Rubinius::MethodTable:0x101401170>: 18 | |
:constant_table, :direct_superclass, :attr_writer, :protected, :alias_method, :module_function, :const_set, :encloser, :name, :append_features, :included, :attr_accessor, :const_missing, :include, :method_table, :superclass=, :attr_reader, :private | |
> | |
> | |
$2 = void |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Breakpoint 1, rubinius::MetaClass::attach (state=0x101204b00, obj=0x101226220, sup=0x0) at vm/builtin/class.cpp:204 | |
204 | |
(gdb) rp already_meta | |
#<MetaClass:Class Object:0x101226220> | |
$1 = void | |
(gdb) rp already_meta->superclass() | |
#<Class(Class):0x101225c70> | |
name: :Class | |
superclass: #<Module(Class):0x101225df0> | |
constants: #<Rubinius::LookupTable:0x101400ed0> |