Skip to content

Instantly share code, notes, and snippets.

View yorickpeterse's full-sized avatar

Yorick Peterse yorickpeterse

View GitHub Profile
/home/yorickpeterse/.rubies/ruby-1.8.7-p374/bin/ruby -r ./siteconf20150102-25402-4mfu9j-0.rb extconf.rb
extconf.rb:8: warning: already initialized constant ToolSet
make clean
make
compiling melbourne.cpp
compiling symbols.cpp
generating parser grammar.y
compiling grammar.cpp
Thread 8 (Thread 0x7fc82c644700 (LWP 13272)):
#0 0x00007fc8319088cf in pthread_cond_wait@@GLIBC_2.3.2 () from /usr/lib/libpthread.so.0
#1 0x000000000088f7d1 in wait (this=<optimized out>, mutex=...)
at /home/yorickpeterse/Private/Projects/ruby/rubinius/vm/util/thread.hpp:455
#2 worker_wait (this=<optimized out>) at vm/gc/finalize.cpp:481
#3 rubinius::FinalizerHandler::perform (this=0x34b3960, state=0x7fc82c643ec0) at vm/gc/finalize.cpp:196
#4 0x000000000088f649 in rubinius::finalizer_handler_tramp (state=0x7fc82c643ec0) at vm/gc/finalize.cpp:74
#5 0x000000000086b556 in rubinius::Thread::in_new_thread (ptr=0x34f7330) at vm/builtin/thread.cpp:283
#6 0x00007fc831903314 in start_thread () from /usr/lib/libpthread.so.0
#7 0x00007fc830a9824d in clone () from /usr/lib/libc.so.6
#include <string.h>
#include <stdio.h>
#include <malloc.h>
%%{
machine test_lexer;
newline = [\n|\r\n]+;
integer = ('+'|'-')?[0-9]+;
operator = ['+''-''*''/''=''%''^']+;
#include <juno/lexer.hpp>
using namespace Juno::Lexing;
#define ADVANCE_COLUMN column = column + (te - ts)
#define ADVANCE_LINE line++; column = 0;
#define ADD_TOKEN(TYPE) \
tokens->push(this->create_token(TYPE, ts, te, line, column)); \
ADVANCE_COLUMN
class Example
def foo
return 10 + 20
end
end
example = Example.new
method = example.method(:foo).executable
Rubinius::JIT.compile(example, method)
# The contents of this block would be arbitrary, it's _not_ tied into any ORM/database/etc.
define_dummy(:stubbed_user) do |attrs|
user = User.new(attrs)
user.stub(:something).and_return('foo')
user
end
describe User do
source 'https://rubygems.org'
gem 'oga'
@yorickpeterse
yorickpeterse / bench.rb
Last active August 29, 2015 14:13
Manually running the Rubinius JIT on a totally legit fib() benchmark.
require 'benchmark/ips'
class Bench
def fact(n)
if n > 1
n * fact(n-1)
else
1
end
end
Ruby: {"name"=>"Yorick", "age"=>22, "location"=>"Netherlands", "anger_level"=>9000}
CAPI: {"name"=>"Yorick", "age"=>22, "location"=>"Netherlands", "anger_level"=>9000}
Racc: {"name"=>"Yorick", "age"=>22, "location"=>"Netherlands", "anger_level"=>9000}
Calculating -------------------------------------
Ruby reuse 2.966k i/100ms
Ruby new 2.934k i/100ms
CAPI reuse 8.044k i/100ms
CAPI new 7.212k i/100ms
Racc reuse 5.075k i/100ms
git clone git@github.com:YorickPeterse/ruby-ll.git
cd ruby-ll
bundle install
rake clean compile
ruby test.rb # see Ruby script below