Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/remogatto/ffi-life

Game Of Life implementation using ffi-inliner
https://github.com/remogatto/ffi-life

Last synced: 14 days ago
JSON representation

Game Of Life implementation using ffi-inliner

Awesome Lists containing this project

README

        

ffi-life
by Andrea Fazzi
http://github.com/remogatto/ffi-life

== DESCRIPTION:

ffi-life is yet another implementation of {The Game Of
Life}[http://en.wikipedia.org/wiki/Conway%27s_Game_of_Life]. The
program is derived from my solution to {Ruby Quiz
#193}[http://rubyquiz.strd6.com/quizzes/193/]. The interesting thing
about ffi-life is that it is a first real usage example of
{ffi-inliner}[http://github.com/remogatto/ffi-inliner] a library to
run C code from Ruby through
{Ruby-FFI}[http://kenai.com/projects/ruby-ffi]. ffi-life is
shipped with a naive benchmark that compares the fast
ffi-inliner version against the pure Ruby version (see the
BENCHMARKS section below). A little injection of *portable* C for a
big improvement in speed!

== FEATURES/PROBLEMS:

* Text based!
* It uses ffi-inliner for very fast cells generation
* It is multiVM: give it a whirl with JRuby and appreciate how fast is
it!

== SYNOPSIS:

Simply open a terminal and run:

ffi-life

For more options execute:

ffi-life --help

== REQUIREMENTS:

* ffi-inliner >= 0.2.1

== DOWNLOAD/INSTALL:

git clone git://github.com/remogatto/ffi-life
cd ffi-life
rake gem:install

== BENCHMARKS:

Here below there are some benchmark results running ffi-life with MRI
Ruby 1.8.7 on my MacBook Core 2 2.16GHz.

andrea@ganimoide:~/src/ffi-life$ ruby bench/bench.rb
user system total real
[ffi-inliner] w: 100 h: 100 ticks: 10 1.450000 0.220000 1.670000 ( 1.696030)
[ffi-inliner[ w: 60 h: 60 ticks: 10 0.520000 0.060000 0.580000 ( 0.584314)
user system total real
[ruby] w: 100 h: 100 ticks: 10 5.200000 0.560000 5.760000 ( 5.812291)
[ruby] w: 60 h: 60 ticks: 10 1.860000 0.210000 2.070000 ( 2.086663)

And it's even faster on JRuby!

andrea@ganimoide:~/src/ffi-life$ jruby bench/bench.rb
user system total real
[ffi-inliner] w: 100 h: 100 ticks: 10 0.970000 0.000000 0.970000 ( 0.970000)
[ffi-inliner[ w: 60 h: 60 ticks: 10 0.310000 0.000000 0.310000 ( 0.310000)
user system total real
[ruby] w: 100 h: 100 ticks: 10 2.100000 0.000000 2.100000 ( 2.100000)
[ruby] w: 60 h: 60 ticks: 10 0.692000 0.000000 0.692000 ( 0.692000)

== LICENSE:

(The MIT License)

Copyright (c) 2009 Andrea Fazzi

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.