Kurt Stephens

Nerd Up!

ruby

Ruby: Fixnum#gcd accepted into MRI

Kurt on Mon, 2010-02-08 18:52.

Ruby rational.rb clean-up and the Fixnum#gcd primitive was refactored into a new MRI extension. Fixnum#gcd is now defined during require ‘rational’.

http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/branches/ruby_1_8/ChangeLog?...

http://redmine.ruby-lang.org/issues/show/2561

See http://kurtstephens.com/node/34 .


Emacs Flymake Ruby Mode

Kurt on Mon, 2009-12-28 03:40.

Adds automatic syntax checking and error highlighting to Ruby code:

http://github.com/purcell/emacs.d/raw/master/site-lisp/flymake-ruby/flym...


Ruby 1.8: Improved Rational performance by 15%

Kurt on Wed, 2009-12-23 21:27.

This should also speed up DateTime. This will not help 1.9 performance.

The attached file is based on MRI 1.8.6 rational.rb.

 > ruby rational_performance.rb 
                                              user     system      total        real
test_it                                  32.930000   3.030000  35.960000 ( 35.971832)
test_it                                  33.840000   2.910000  36.750000 ( 36.758585)
test_it ks_rational                      29.110000   2.460000  31.570000 ( 31.572762)

Overview:

  • case x; when Foo; ...; end is faster than if Foo.kind_of?(x).

Ruby: Caching #to_s for immutables (and a possible future for constant-folding)

Kurt on Mon, 2009-11-23 02:07.

Reference: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/26869

I have a proof-of-concept patch to MRI that caches #to_s values for immutable values. It is implemented using a few fixed-size hash tables.

It reduces the number of #to_s result objects by 1890 during the MRI test suite for NilClass#to_s, TrueClass#to_s, FalseClass#to_s, Symbol#to_s, and Float#to_s.

It requires a minor semantic change to Ruby core. This minor change could cascade into a huge performance improvement for all Ruby implementations — as will be illustrated later:

#to_s may return frozen Strings.

cabar - An Extensible Software Component Mangement System

Kurt on Wed, 2009-06-24 22:05.

Cabar – an extensible software component backplane for managing software components.

http://cabar.rubyforge.org/

http://github.com/kstephens/cabar/tree/master


Ruby: Performance of Symbol Construction

Kurt on Sun, 2008-11-23 03:54.

Measurements of Symbol Constructor Expressions.

n=10_000_000

ruby 1.8.6 (2008-08-08 patchlevel 286) [i686-linux]:

> /cnu/bin/ruby symbol_benchmark.rb
                               user     system      total        real
Null Test                  0.740000   0.000000   0.740000 (  0.742914)
'foo_bar'                  1.670000   0.000000   1.670000 (  1.661374)
"foo_bar"                  1.620000   0.000000   1.620000 (  1.625221)
:foo_bar                   0.890000   0.000000   0.890000 (  0.886903)
:'foo_bar'                 0.880000   0.000000   0.880000 (  0.878555)
<br class="clear" />

How to duplicate DataMapper objects

Kurt on Sun, 2008-11-16 21:04.

How to create a deep clone of a DataMapper::Resource object so it can be stored in a different repository.

This does not work:

obj = Foo.first
obj = obj.dup
repository(:other) { obj.save }

<br class="clear" />

Ruby DataMapper : dm-more Gem cannot be installed

Kurt on Sun, 2008-07-20 06:13.

dm-more depends on merb_datamapper (!?!) version 0.9.3 which does not appear to exist yet:

++ gem install dm-more
ERROR:  Error installing dm-more:
	dm-more requires merb_datamapper (= 0.9.3, runtime)

Not sure what to do about it.


Syndicate content