Skip to content

Instantly share code, notes, and snippets.

@tka tka/benchmark.rb
Last active Aug 29, 2015

What would you like to do?
golang 1.5 shared library + ruby ffi
# 搭配 服用
require 'ffi'
require 'benchmark'
module LibGo
extend FFI::Library
ffi_lib './'
attach_function :fib, [:int], :int
def fib(i)
return i if i < 2
return fib(i-2)+fib(i-1)
n=10000 do |x|{ n.times{ fib(16); }}{ n.times{ LibGo.fib(16) }}
user system total real
1.130000 0.000000 1.130000 ( 1.132376)
0.060000 0.000000 0.060000 ( 0.068342)

This comment has been minimized.

Copy link

benjaminpelc commented Aug 19, 2015

Hi, I have been trying to find out how do exactly this, how did you create Can't seem to find anywhere how to make the .so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.