[#368826] ANN: home_run 0.9.1 Released — Jeremy Evans <code@...>

= home_run

14 messages 2010/09/01

[#368894] uninitialized constant NArray (Name Error) — Abder-Rahman Ali <abder.rahman.ali@...>

Following section (2) here:

12 messages 2010/09/02

[#368914] p vs. print — Abder-Rahman Ali <abder.rahman.ali@...>

I wrote the following scripts from section (2) here:

24 messages 2010/09/02
[#368915] Re: p vs. print — Alex Stahl <astahl@...5.com> 2010/09/02

Ruby uses "puts", not "print". "p" is short for "puts".

[#368977] Read cookie — Pål Bergström <pal@...>

How can I get the value of a browser cookie with Ruby?

29 messages 2010/09/03
[#368978] Re: Read cookie — Brian Candler <b.candler@...> 2010/09/03

P奪l Bergstr旦m wrote:

[#368984] Re: Read cookie — Pål Bergström <pal@...> 2010/09/03

Brian Candler wrote:

[#369036] ruby_archive 0.1.0 released — Jonathan Nielsen <jonathan@...>

After a summer of working on various ways to implement it, I'm happy to

10 messages 2010/09/03

[#369106] A better idiomatic way of doing this?! — Tim Romberg <tim.jakobsson@...>

Hi Im new at Ruby and been struggling with this lab I have for a course

12 messages 2010/09/05

[#369113] unable to open X server `' (Magick::ImageMagickError) — Abder-Rahman Ali <abder.rahman.ali@...>

I have written a Ruby script "dicom_info.rb", and when I try running

16 messages 2010/09/06
[#369119] Re: unable to open X server `' (Magick::ImageMagickError) — Brian Candler <B.Candler@...> 2010/09/06

On Mon, Sep 06, 2010 at 12:42:11PM +0900, Abder-Rahman Ali wrote:

[#369132] Re: unable to open X server `' (Magick::ImageMagickError) — Abder-Rahman Ali <abder.rahman.ali@...> 2010/09/06

Thanks a lot Brian.

[#369139] Re: unable to open X server `' (Magick::ImageMagickError) — Brian Candler <B.Candler@...> 2010/09/06

On Mon, Sep 06, 2010 at 11:55:32PM +0900, Abder-Rahman Ali wrote:

[#369140] Re: unable to open X server `' (Magick::ImageMagickError) — Abder-Rahman Ali <abder.rahman.ali@...> 2010/09/06

So, do you suggest installing "cygwin"?

[#369159] Re: unable to open X server `' (Magick::ImageMagickError) — Roger Pack <rogerpack2005@...> 2010/09/06

> you suggest installing "cygwin"?

[#369124] Odd functional programming question — Peter Hickman <peterhickman386@...>

Ok this is probably not really functional programming but I was just

10 messages 2010/09/06

[#369169] How do I request a HTTPS page? — Samuel Sternhagen <samatoms@...>

I would like to access a https page from irb

14 messages 2010/09/06

[#369226] What OS do you use for Ruby development? — Nick Hird <nrhird@...>

I don't want to start any OS wars. I was just curious as to what OS

67 messages 2010/09/07

[#369301] Nokogiri and LibXML — unbewusst.sein@... (Une B騅ue)

Each time i launch a script using Nokogiri i get :

12 messages 2010/09/08

[#369302] Receiving array naturally? — Terry Michaels <spare@...>

As I learn Ruby, I find a lot of flexibility in the syntax. I was

14 messages 2010/09/08

[#369389] Key Associated w/ Maximum Value in Hash — Timothy Baron <timothy.baron@...>

Simple question: what's the cleanest way to retrieve a key associated

11 messages 2010/09/09

[#369477] How to do foo.chomp!.rstrip!.downcase! ? — Geometric Patterns <geometric.patterns@...>

15 messages 2010/09/10

[#369623] Ruby packaging in Debian and Ubuntu: Mythbusting and FAQ — Lucas Nussbaum <lucas@...>

Hi,

11 messages 2010/09/12

[#369638] Declarative relations between object attributes — Knut Franke <knut.franke@...>

Some time ago I stumbled over Cells[1], a Common Lisp extension allowing

16 messages 2010/09/12

[#369710] Encoding error while installing rails on ruby 1.9.2 — Bek Bek <bekis3@...>

Hello everybody,

11 messages 2010/09/14

[#369796] Ruby Multi-threading? — Terry Michaels <spare@...>

I read a Ruby e-book recently that indicated that although Ruby has

12 messages 2010/09/15

[#369952] Developing for Ruby on Windows? — Tom Wardrop <tom@...>

I've heard a lot of criticism about developing for Ruby on Windows, but

11 messages 2010/09/17

[#370039] Ruby-based data language — Intransition <transfire@...>

Has anyone ever endeavored to create a data/configuration file format

14 messages 2010/09/19

[#370053] Getting GUI for ruby for Linux running (QT or wxWidget)? — Markus Fischer <markus@...>

Hi,

23 messages 2010/09/19
[#370054] Re: Getting GUI for ruby for Linux running (QT or wxWidget)? — Markus Fischer <markus@...> 2010/09/19

On 20.09.2010 01:14, Markus Fischer wrote:

[#370116] Re: Getting GUI for ruby for Linux running (QT or wxWidget)? — Quintus <sutniuq@...> 2010/09/20

-----BEGIN PGP SIGNED MESSAGE-----

[#370164] Re: Getting GUI for ruby for Linux running (QT or wxWidget)? — Ryan Melton <ryanmelt@...> 2010/09/21

qt does have a new gem I put together:

[#370205] QT works! (was: Re: Getting GUI for ruby for Linux running (QT or wxWidget)) — Markus Fischer <markus@...> 2010/09/21

Hi,

[#370127] An elegant way... — "F. Senault" <fred@...>

Hello everybody.

23 messages 2010/09/20

[#370210] The Great Ruby GUI Toolkit Roundup — Ed Howland <ed.howland@...>

Hi,

15 messages 2010/09/21

[#370257] having problems with open4 and stuck forked processes — Tim Uckun <timuckun@...>

I am running a batch process which uses the wkhtmltoimage-i386 binary

13 messages 2010/09/22
[#370268] Re: having problems with open4 and stuck forked processes — Robert Klemme <shortcutter@...> 2010/09/22

On Wed, Sep 22, 2010 at 2:31 PM, Tim Uckun <timuckun@gmail.com> wrote:

[#370294] Re: having problems with open4 and stuck forked processes — Tim Uckun <timuckun@...> 2010/09/22

> What do you mean by that? =C2=A0Goes the timeout undetected? =C2=A0Can't =

[#370309] Re: having problems with open4 and stuck forked processes — Robert Klemme <shortcutter@...> 2010/09/23

On 23.09.2010 01:59, Tim Uckun wrote:

[#370289] Sorting problem with an Array of Arrays — Paul <tester.paul@...>

Hi there, I have an array of arrays that looks like the following:

15 messages 2010/09/22

[#370296] Ruby Installation Error — Tridib Bandopadhyay <tridib04@...>

I am trying this command to build the ruby interpreter

20 messages 2010/09/23
[#370689] Re: Ruby Installation Error — Brian Candler <b.candler@...> 2010/09/29

Tridib Bandopadhyay wrote:

[#370319] to make dot method dot method work? — Pen Ttt <myocean135@...>

here is the class

14 messages 2010/09/23

[#370373] how do i force ruby to release memory — Amit Tomar <amittomer25@...>

Hi all,

19 messages 2010/09/24
[#370374] Re: how do i force ruby to release memory — Robert Klemme <shortcutter@...> 2010/09/24

On Fri, Sep 24, 2010 at 7:36 AM, Amit Tomar <amittomer25@yahoo.com> wrote:

[#370379] Re: how do i force ruby to release memory — Amit Tomar <amittomer25@...> 2010/09/24

Robert Klemme wrote:

[#370380] Re: how do i force ruby to release memory — Jes俍 Gabriel y Gal疣 <jgabrielygalan@...> 2010/09/24

On Fri, Sep 24, 2010 at 10:31 AM, Amit Tomar <amittomer25@yahoo.com> wrote:

[#370383] Re: how do i force ruby to release memory — Amit Tomar <amittomer25@...> 2010/09/24

Jes炭s Gabriel y Gal叩n wrote:

[#370388] How to delete the browser cache through ruby — Arihan Sinha <arihan_sinha@...>

Hi All,

11 messages 2010/09/24

[#370590] Point me to help w/ multithreading in 1.9.2-p0 — Alex Stahl <astahl@...5.com>

Hi Folks - A week or two ago, I pinged this list for recommendations on

11 messages 2010/09/28
[#370593] Re: Point me to help w/ multithreading in 1.9.2-p0 — Alex Stahl <astahl@...5.com> 2010/09/28

Nevermind... figured it out.

[#370640] puts and return — Jim Haungs <jhaungs@...>

10.times do |i|

14 messages 2010/09/28

[#370661] Color sequences in ri on Windows — Eric Christopherson <echristopherson@...>

After installing some gems, the system recommended that I refresh ri

11 messages 2010/09/28

[#370721] The beauty of Ruby through examples — Adriano Ferreira <adrfer@...>

Hey all,

33 messages 2010/09/29

[#370740] Can't upgrade ruby on Snow Leopard — Ast Jay <azzzz@...>

I've followed the instructions here:

13 messages 2010/09/29

[#370796] How to prevent overwriting methods by accident? — Stefan Salewski <mail@...>

In Ruby we can add new methods to existing classes.

13 messages 2010/09/30
[#370797] Re: How to prevent overwriting methods by accident? — Jeremy Bopp <jeremy@...> 2010/09/30

On 9/30/2010 2:15 PM, Stefan Salewski wrote:

[#370800] Re: How to prevent overwriting methods by accident? — Alex Stahl <astahl@...5.com> 2010/09/30

But is there a way to call the original method instead of just quitting

ANN: home_run 0.9.1 Released

From: Jeremy Evans <code@...>
Date: 2010-09-01 16:16:29 UTC
List: ruby-talk #368826
= home_run

home_run is an implementation of ruby's Date/DateTime classes in C,
with much better performance (20-200x) than the version in the
standard library, while being almost completely compatible.

== Performance increase (microbenchmarks)

The speedup you'll get depends mostly on your version of ruby, but
also on your operating system, platform, and compiler.  Here are
some comparative results for common methods:

  #                 | i386  | i386  | i386  | i386  | amd64 |
  #                 |Windows| Linux | Linux | Linux |OpenBSD|
  #                 | 1.8.6 | 1.8.7 | 1.9.1 | 1.9.2 | 1.9.2 |
  #                 |-------+-------+-------+------ +-------|
  Date.civil        |   82x |   66x |  27x  |  21x  |  14x  |
  Date.parse        |   56x |   56x |  33x  |  30x  |  25x  |
  Date.today        |   17x |    6x |   2x  |   2x  |   2x  |
  Date.strptime     |   43x |   62x |  63x  |  37x  |  23x  |
  DateTime.civil    |  252x |  146x |  52x  |  41x  |  17x  |
  DateTime.parse    |   52x |   54x |  32x  |  27x  |  20x  |
  DateTime.now      |   78x |   35x |  11x  |   8x  |   4x  |
  DateTime.strptime |   63x |   71x |  58x  |  35x  |  23x  |
  Date#strftime     |  156x |  104x | 110x  |  70x  |  62x  |
  Date#+            |   34x |   32x |   5x  |   5x  |   4x  |
  Date#<<           |  177x |  220x |  86x  |  72x  |  40x  |
  Date#to_s         |   15x |    6x |   5x  |   4x  |   2x  |
  DateTime#strftime |  146x |  107x | 114x  |  71x  |  60x  |
  DateTime#+        |   34x |   37x |   8x  |   6x  |   3x  |
  DateTime#<<       |   88x |  106x |  40x  |  33x  |  16x  |
  DateTime#to_s     |  144x |   47x |  54x  |  29x  |  24x  |

== Real world difference

The standard library Date class is slow enough to be the
bottleneck in much (if not most) of code that uses it.
Here's a real world benchmark showing the retrieval of
data from a database (using Sequel), first without home_run,
and then with home_run.

  $ script/console production
  Loading production environment (Rails 2.3.5)
  >> require 'benchmark'
  => false
  >> puts Benchmark.measure{Employee.all}
    0.270000   0.020000   0.290000 (  0.460604)
  => nil
  >> puts Benchmark.measure{Notification.all}
    2.510000   0.050000   2.560000 (  2.967896)
  => nil

  $ home_run script/console production
  Loading production environment (Rails 2.3.5)
  >> require 'benchmark'
  => false
  >> puts Benchmark.measure{Employee.all}
    0.100000   0.000000   0.100000 (  0.114747)
  => nil
  >> puts Benchmark.measure{Notification.all}
    0.860000   0.010000   0.870000 (  0.939594)

Without changing any application code, there's a 4x
increase when retrieving all employees, and a 3x
increase when retrieving all notifications.  The
main reason for the performance difference between
these two models is that Employee has 5 date columns,
while Notification only has 3.

== Installing the gem

  gem install home_run

The standard gem requires compiling from source, so you need a working
compiler toolchain.  Since few Windows users have a working compiler
toolchain, a windows binary gem is available that works on both 1.8
and 1.9.

== Installing into site_ruby

This is only necessary on ruby 1.8, as on ruby 1.9, gem directories
come before the standard library directories in the load path.

After installing the gem:

  home_run --install

Installing into site_ruby means that ruby will always use home_run's
Date/DateTime classes instead of the ones in the standard library.

If you ever want to uninstall from site_ruby:

  home_run --uninstall

== Running without installing into site_ruby

Just like installing into site_ruby, this should only be necessary
on ruby 1.8.

If you don't want to install into site_ruby, you can use home_run's
Date/DateTime classes for specific programs by running your script
using home_run:

  home_run ruby ...
  home_run irb ...
  home_run unicorn ...
  home_run rake ...

This manipulates the RUBYLIB and RUBYOPT environment variables so
that home_run's Date/DateTime classes will be used.

You can also just require the library:

  require 'home_run'

This should only be used as a last resort.  Because rubygems requires
date, you can end up with situations where the Date instances created
before the require use the standard library version of Date, while the
Date instances created after the require use this library's version.
However, in some cases (such as on Heroku), this is the only way to
easily use this library.

== Running the specs

You can run the rubyspec based specs after installing the gem, if
you have MSpec installed (gem install mspec):

  home_run --spec

If there are any failures, please report them as a bug.

== Running comparative benchmarks

You can run the benchmarks after installing the gem:

  home_run --bench

The benchmarks compare home_run's Date/DateTime classes to the
standard library ones, showing you the amount of time an average
call to each method takes for both the standard library and
home_run, and the number of times home_run is faster or slower.
Output is in CSV, so an entry like this:

  Date._parse,362562,10235,35.42

means that:

* The standard library's Date._parse averaged 362,562 nanoseconds
  per call.
* home_run's Date._parse averaged 10,235 nanoseconds per call.
* Therefore, home_run's Date._parse method is 35.42 times faster

The bench task tries to be fair by ensuring that it runs the
benchmark for at least two seconds for both the standard
library and home_run's versions.

== Usage

home_run aims to be compatible with the standard library, except
for differences mentioned below.  So you can use it the same way
you use the standard library.

== Differences from standard library

* Written in C (mostly) instead of ruby.  Stores information in a
  C structure, and therefore has a range limitation.  home_run
  cannot handle dates after 5874773-08-15 or before -5877752-05-08
  on 32-bit platforms (with larger limits for 64-bit platforms).
* The Date class does not store fractional days (e.g. hours, minutes),
  or offsets. The DateTime class does handle fractional days and
  offsets.
* The DateTime class stores fractional days as the number of
  nanoseconds since midnight, so it cannot deal with differences
  less than a nanosecond.
* Neither Date nor DateTime uses rational.  Places where the standard
  library returns rationals, home_run returns integers or floats.
* Because rational is not used, it is not required.  This can break
  other libraries that use rational without directly requiring it.
* There is no support for modifying the date of calendar reform, the
  sg arguments are ignored and the Gregorian calendar is always used.
  This means that julian day 0 is -4173-11-24, instead of -4712-01-01.
* The undocumented Date#strftime format modifiers are not supported.
* The DateTime offset is checked for reasonableness. home_run
  does not support offsets with an absolute difference of more than
  14 hours from UTC.
* DateTime offsets are stored in minutes, so it will round offsets
  with fractional minutes to the nearest minute.
* All public class and instance methods for both Date and DateTime
  are implemented, except that the allocate class method is not
  available and on 1.9, _dump and _load are used instead of
  marshal_dump and marshal_load.
* Only the public API is compatible, the private methods in the
  standard library are not implemented.
* The marshalling format differs from the one used by the standard
  library.  Note that the 1.8 and 1.9 standard library date
  marshalling formats differ from each other.
* Date#step treats the step value as an integer, so it cannot handle
  steps of fractional days.  DateTime#step can handle fractional
  day steps, though.
* When parsing the %Q modifier in _strptime, the hash returned
  includes an Integer :seconds value and a Float :sec_fraction
  value instead of a single rational :seconds value.
* The string returned by #inspect has a different format, since it
  doesn't use rational.
* The conversion of 2-digit years to 4-digit years in Date._parse
  is set to true by default.  On ruby 1.8, the standard library
  has it set to false by default.
* You can use the Date::Format::STYLE hash to change how to parse
  DD/DD/DD and DD.DD.DD date formats, allowing you to get ruby 1.9
  behavior on 1.8 or vice-versa.  This is probably the only new
  feature in that isn't in the standard library.

Any other differences will either be documented here or considered
bugs, so please report any other differences you find.

== Known incompatibilities

Some other libraries are known to be incompatible with this
extension due to the above differences:

* Date::Performance - Date#<=> assumes @ajd instance variable
  (unnecessary anyway, as home_run is faster)
* ruby-ole - Depends on DateTime.allocate/#initialize

== Reporting issues/bugs

home_run uses GitHub Issues for tracking issues/bugs:

  http://github.com/jeremyevans/home_run/issues

== Contributing

The source code is on GitHub:

  http://github.com/jeremyevans/home_run

To get a copy:

  git clone git://github.com/jeremyevans/home_run.git

There are a few requirements:

* rake
* rake-compiler
* MSpec (not RSpec) for running the specs.  The specs are based on
  the rubyspec specs, which is why they use MSpec.
* RDoc 2.5.10+ if you want to build the documentation.
* Ragel 6.5+ if you want to modify the ragel parser.

== Compiling

To compile the library from a git checkout, after installing the
requirements:

  rake compile

== Testing

The default rake task runs the specs, so just run:

  rake

You need to compile the library and install MSpec before running the
specs.

== Benchmarking

To see the speedup that home_run gives you over the standard library:

  rake bench

To see how much less memory home_run uses compared to the standard
library:

  rake mem_bench

To see how much less garbage is created when instantiating objects
with home_run compared to the standard library:

  rake garbage_bench

If you want to run all three benchmarks at once:

  rake bench_all

== Platforms Supported

home_run has been tested on the following:

=== Operating Systems/Platforms

* Linux (x86_64, i386)
* Mac OS X 10.6 (x86_64, i386), 10.5 (i386)
* OpenBSD (amd64, i386)
* Solaris 10 (sparc)
* Windows XP (i386)
* Windows 7 (x64)

=== Compiler Versions

* gcc (3.3.5, 4.0.1, 4.2.1, 4.4.3, 4.5.0)
* Sun Studio Compiler (5.9)

=== Ruby Versions

* jruby cext branch (as of commit 1969c504229bfd6f2de1, 2010-08-23,
  compiles and runs specs correctly, segfaults on benchmarks)
* rbx head (as of commit 0e265b92727cf3536053, 2010-08-16)
* ruby 1.8.6 (p0, p110, p398, p399)
* ruby 1.8.7 (p174, p248, p299, p302)
* ruby 1.9.1 (p243, p378, p429, p430)
* ruby 1.9.2 (p0)
* ruby head

If your platform, compiler version, or ruby version is not listed
above, please test and send me a report including:

  * Your operating system and platform (e.g. i386, x86_64/amd64)
  * Your compiler
  * Your ruby version
  * The output of home_run --spec
  * The output of home_run --bench

== Author

Jeremy Evans <code@jeremyevans.net>
-- 
Posted via http://www.ruby-forum.com/.

In This Thread

Prev Next