Skip to content

Instantly share code, notes, and snippets.

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'))
+
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
#!/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}" }
#!/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
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)
* 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
$ ./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
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
#!/usr/bin/ruby
class Flash < Hash
class List < Array
def to_s
map {|v| "<li>#{v}</li>" }.join('')
end
end
def []= k, v
super(k, List.new(fetch(k, []) + [v]))
diff --git a/examples/orm.rb b/examples/orm.rb
index bfb475d..1fb9717 100755
--- a/examples/orm.rb
+++ b/examples/orm.rb
@@ -1,5 +1,6 @@
#!/usr/bin/env ruby
require_relative '../lib/swift-orm'
+require_relative '../lib/swift-orm/types'
require 'etc'
require 'pp'