Skip to content

Instantly share code, notes, and snippets.

diff --git a/examples/scheme.rb b/examples/scheme.rb
index 52e5f98..b06c1e7 100755
--- a/examples/scheme.rb
+++ b/examples/scheme.rb
@@ -5,12 +5,12 @@ require 'pp'
class User < Swift::Scheme
store :users
- attribute :id, Swift::Type::Integer, serial: true, key: true
- attribute :name, Swift::Type::String
$ ./simple.sh -d mysql -r 10000 -n 1
-- driver: mysql rows: 10000 runs: 1 --
user system total real
dm #create 3.600000 0.520000 4.120000 ( 7.527122)
dm #select 1.890000 0.100000 1.990000 ( 1.997144)
dm #update 7.750000 0.720000 8.470000 ( 11.151092)
virt: 1051076kB res: 1003404kB
user system total real
* DataMapper, Active Record and Swift comparisons with GC disabled.
* #create runs once creating the rows.
* #select and #update iterates through them <runs> times.
* memory usage is measured as (total rss of process after - before) benchmark is run.
-- driver: mysql rows: 5000 runs: 5 --
benchmark sys user total real rss
dm #create 0.170000 1.780000 1.950000 3.655825 108.36m
dm #select 0.300000 4.420000 4.720000 4.739661 322.62m
module Rack
class InputEncoder
def initialize app
@app = app
end
def call env
env["rack.input"] = IO.new(env["rack.input"])
@app.call(env)
end
class IO < DelegateClass(IO)
#!/usr/bin/ruby
require 'pp'
sets = [
[1, 2, 3],
[10, 20, 30, 40, 50, 55, 56],
[100, 200, 300, 400, 500, 600, 700]
]
scale = sets.flatten.max
#!/usr/bin/ruby
require 'gems/environment'
require 'em-jack'
require 'em-http'
EM.run do
jack = EMJack::Connection.new
jack.use('stalk') do
5.times {|n| jack.put "hello #{n+1}" }
diff --git a/examples/db.rb b/examples/db.rb
index da5b728..c43daf1 100755
--- a/examples/db.rb
+++ b/examples/db.rb
@@ -8,9 +8,9 @@ require 'swift/migrations'
class User < Swift::Scheme
store :users
- attribute :id, Swift::Type::Integer, serial: true, key: true
- attribute :name, Swift::Type::String
diff --git a/examples/associations.rb b/examples/associations.rb
new file mode 100755
index 0000000..27d95f5
--- /dev/null
+++ b/examples/associations.rb
@@ -0,0 +1,53 @@
+#!/usr/bin/env ruby
+
+$:.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
+
#include <ruby/ruby.h>
#include <time.h>
#include <unistd.h>
#define CONST_GET(scope, constant) rb_const_get(scope, rb_intern(constant))
VALUE day_secs;
VALUE cDateTime;
VALUE fNewBang;
#include <ruby.h>
VALUE blocking_function(void *data) {
throw "die die die";
}
VALUE run(VALUE self) {
try {
rb_thread_blocking_region(blocking_function, 0, 0, 0);
}