localmemcache 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/AUTHORS +1 -0
- data/COPYING +21 -0
- data/LICENSE +3 -0
- data/Makefile.in +18 -0
- data/README +83 -0
- data/Rakefile +78 -0
- data/VERSION +1 -0
- data/aclocal.m4 +3 -0
- data/configure +5254 -0
- data/configure.in +42 -0
- data/site/index.html +70 -0
- data/site/style.css +37 -0
- data/src/Makefile.in +53 -0
- data/src/lmc_config.h.in +4 -0
- data/src/lmc_error.c +18 -0
- data/src/lmc_error.h +19 -0
- data/src/lmc_hashtable.c +104 -0
- data/src/lmc_hashtable.h +33 -0
- data/src/lmc_lock.c +65 -0
- data/src/lmc_lock.h +22 -0
- data/src/lmc_shm.c +92 -0
- data/src/lmc_shm.h +22 -0
- data/src/lmc_valloc.c +324 -0
- data/src/lmc_valloc.h +31 -0
- data/src/localmemcache.c +130 -0
- data/src/localmemcache.h +33 -0
- data/src/ruby-binding/extconf.rb +14 -0
- data/src/ruby-binding/localmemcache.rb +32 -0
- data/src/ruby-binding/rblocalmemcache.c +119 -0
- data/src/tests/alloc +11 -0
- data/src/tests/alloc.rb +61 -0
- data/src/tests/bacon.rb +301 -0
- data/src/tests/bench +11 -0
- data/src/tests/bench.rb +46 -0
- data/src/tests/extconf.rb +14 -0
- data/src/tests/lmc +11 -0
- data/src/tests/lmc.rb +85 -0
- data/src/tests/lmctestapi.c +162 -0
- data/src/tests/runtest.sh +9 -0
- data/src/tests/shm +11 -0
- data/src/tests/shm.rb +20 -0
- data/src/tests/torture.rb +56 -0
- data/src/tests/ttalloc +11 -0
- data/src/tests/ttalloc.rb +47 -0
- data/src/tests/ttlmc +11 -0
- data/src/tests/ttlmc.rb +21 -0
- metadata +99 -0
data/src/tests/shm
ADDED
data/src/tests/shm.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'lmctestapi'
|
2
|
+
|
3
|
+
def tmeasure(c, &block)
|
4
|
+
_then = Time.now
|
5
|
+
c.times { block.call }
|
6
|
+
now = Time.now
|
7
|
+
puts "#{(now - _then)*1000} ms"
|
8
|
+
end
|
9
|
+
|
10
|
+
$lm = SHM.new("foo")
|
11
|
+
|
12
|
+
v= nil
|
13
|
+
ev = nil
|
14
|
+
1000000.times {|i|
|
15
|
+
v = $lm.get(3)
|
16
|
+
$lm.set(3, v.to_i + 1)
|
17
|
+
ev = v.to_i + 1
|
18
|
+
}
|
19
|
+
|
20
|
+
puts "#{$$} v: #{v}"
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# Copyright (C) 2009 Sven C. Koehler <schween@snafu.de>
|
2
|
+
# torture.rb is freely distributable under the terms of an MIT-style license.
|
3
|
+
# See http://www.opensource.org/licenses/mit-license.php.
|
4
|
+
|
5
|
+
$rand_seed = (ENV['TTSEED'] || Time.now).to_i
|
6
|
+
puts "torture rand seed: #{$rand_seed}"
|
7
|
+
srand $rand_seed
|
8
|
+
|
9
|
+
$stdout.sync = true
|
10
|
+
$big = 2**34
|
11
|
+
class TortureTesting
|
12
|
+
class << self
|
13
|
+
def string(size=500)
|
14
|
+
@cs ||= (0..255).to_a
|
15
|
+
(0...size).collect { @cs[Kernel.rand(256)].chr }.join
|
16
|
+
end
|
17
|
+
def float(max=$big) rand * max end
|
18
|
+
def numeric(max=$big) rand(max) end
|
19
|
+
def nil() nil end
|
20
|
+
def any() self.send([:numeric, :float, :string, :nil][rand(4)]) end
|
21
|
+
|
22
|
+
def run(n=2000, *args, &block) @calls = args; torture(n, &block) end
|
23
|
+
def rand_param(k)
|
24
|
+
return self.send(k) if Symbol === k
|
25
|
+
if Hash === k
|
26
|
+
return k.map {|k,v| [k, rand_param(v)] }.inject({}){|h,p|
|
27
|
+
k, v = p; h[k] = v; h}
|
28
|
+
end
|
29
|
+
k
|
30
|
+
end
|
31
|
+
def randomize_parameters(d) d.map {|p| rand_param(p) } end
|
32
|
+
def no_progress() @no_progress = 1; end
|
33
|
+
|
34
|
+
def torture(n=2000, &handle_exception)
|
35
|
+
puts "Starting torture: #{n}"
|
36
|
+
n.times {|c|
|
37
|
+
$stdout.write "#{c}\r" if !@no_progress
|
38
|
+
d = @calls[rand(@calls.size)]
|
39
|
+
d << [] if d.size == 2
|
40
|
+
_obj, method, parameter_description = d
|
41
|
+
obj = Symbol === _obj ? self.send(obj) : _obj
|
42
|
+
begin
|
43
|
+
para = randomize_parameters(parameter_description)
|
44
|
+
obj.send(*([method] + para))
|
45
|
+
rescue Exception => e
|
46
|
+
r = handle_exception.call(obj, para, e) if handle_exception
|
47
|
+
if r
|
48
|
+
puts "FAILED #{method}: #{para.inspect}"
|
49
|
+
break
|
50
|
+
end
|
51
|
+
end
|
52
|
+
}
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
data/src/tests/ttalloc
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
$DIR=File.dirname(__FILE__)
|
2
|
+
['.', '../'].each {|p| $:.unshift File.join($DIR, p) }
|
3
|
+
|
4
|
+
require 'torture'
|
5
|
+
require 'lmctestapi'
|
6
|
+
|
7
|
+
$a = Alloc.new(200000)
|
8
|
+
|
9
|
+
class TortureTesting
|
10
|
+
def self.alloc_v
|
11
|
+
rand($a.largest_chunk).to_i
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Alloc
|
16
|
+
def s_get(s)
|
17
|
+
@va ||= []
|
18
|
+
@va << get(s)
|
19
|
+
end
|
20
|
+
|
21
|
+
def dispose_random
|
22
|
+
i = rand(@va.size)
|
23
|
+
v = @va[i]
|
24
|
+
@va[i] = 0
|
25
|
+
dispose(v) if v != 0
|
26
|
+
end
|
27
|
+
|
28
|
+
def dealloc_all
|
29
|
+
@va.each_with_index {|v, i|
|
30
|
+
@va[i] = 0
|
31
|
+
dispose(v) if v != 0
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
TortureTesting.no_progress
|
37
|
+
|
38
|
+
|
39
|
+
TortureTesting.run(200000,
|
40
|
+
[$a, :s_get, [:alloc_v]],
|
41
|
+
[$a, :dispose_random]
|
42
|
+
) {|a, para, e|
|
43
|
+
}
|
44
|
+
|
45
|
+
$a.dealloc_all
|
46
|
+
|
47
|
+
#$a.dump
|
data/src/tests/ttlmc
ADDED
data/src/tests/ttlmc.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
$DIR=File.dirname(__FILE__)
|
2
|
+
['.', '../', '../ruby-binding/'].each {|p| $:.unshift File.join($DIR, p) }
|
3
|
+
|
4
|
+
require 'torture'
|
5
|
+
require 'localmemcache'
|
6
|
+
|
7
|
+
$h = LocalMemCache.new :namespace=>'torture', :size_mb => 200
|
8
|
+
|
9
|
+
class TortureTesting
|
10
|
+
def self.rand_index
|
11
|
+
rand(9999)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
TortureTesting.no_progress
|
16
|
+
|
17
|
+
TortureTesting.run(200_000,
|
18
|
+
[$h, :get, [:rand_index]],
|
19
|
+
[$h, :set, [:rand_index, :any]],
|
20
|
+
[$h, :delete, [:rand_index]]
|
21
|
+
)
|
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: localmemcache
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sven C. Koehler
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-06 00:00:00 +00:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Localmemcache aims to be faster than using memcached locally by using shared memory, but providing a similar interface.
|
17
|
+
email: schween@snafu.de
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions:
|
21
|
+
- configure
|
22
|
+
- src/ruby-binding/extconf.rb
|
23
|
+
extra_rdoc_files: []
|
24
|
+
|
25
|
+
files:
|
26
|
+
- AUTHORS
|
27
|
+
- COPYING
|
28
|
+
- LICENSE
|
29
|
+
- Makefile.in
|
30
|
+
- README
|
31
|
+
- Rakefile
|
32
|
+
- VERSION
|
33
|
+
- aclocal.m4
|
34
|
+
- configure
|
35
|
+
- configure.in
|
36
|
+
- site/index.html
|
37
|
+
- site/style.css
|
38
|
+
- src/Makefile.in
|
39
|
+
- src/lmc_config.h.in
|
40
|
+
- src/lmc_error.c
|
41
|
+
- src/lmc_error.h
|
42
|
+
- src/lmc_hashtable.c
|
43
|
+
- src/lmc_hashtable.h
|
44
|
+
- src/lmc_lock.c
|
45
|
+
- src/lmc_lock.h
|
46
|
+
- src/lmc_shm.c
|
47
|
+
- src/lmc_shm.h
|
48
|
+
- src/lmc_valloc.c
|
49
|
+
- src/lmc_valloc.h
|
50
|
+
- src/localmemcache.c
|
51
|
+
- src/localmemcache.h
|
52
|
+
- src/ruby-binding/extconf.rb
|
53
|
+
- src/ruby-binding/localmemcache.rb
|
54
|
+
- src/ruby-binding/rblocalmemcache.c
|
55
|
+
- src/tests/alloc
|
56
|
+
- src/tests/alloc.rb
|
57
|
+
- src/tests/bacon.rb
|
58
|
+
- src/tests/bench
|
59
|
+
- src/tests/bench.rb
|
60
|
+
- src/tests/extconf.rb
|
61
|
+
- src/tests/lmc
|
62
|
+
- src/tests/lmc.rb
|
63
|
+
- src/tests/lmctestapi.c
|
64
|
+
- src/tests/runtest.sh
|
65
|
+
- src/tests/shm
|
66
|
+
- src/tests/shm.rb
|
67
|
+
- src/tests/torture.rb
|
68
|
+
- src/tests/ttalloc
|
69
|
+
- src/tests/ttalloc.rb
|
70
|
+
- src/tests/ttlmc
|
71
|
+
- src/tests/ttlmc.rb
|
72
|
+
has_rdoc: false
|
73
|
+
homepage: http://localmemcache.rubyforge.org/
|
74
|
+
post_install_message:
|
75
|
+
rdoc_options: []
|
76
|
+
|
77
|
+
require_paths:
|
78
|
+
- src/ruby-binding
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
version:
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: "0"
|
90
|
+
version:
|
91
|
+
requirements: []
|
92
|
+
|
93
|
+
rubyforge_project: localmemcache
|
94
|
+
rubygems_version: 1.0.1
|
95
|
+
signing_key:
|
96
|
+
specification_version: 2
|
97
|
+
summary: Efficiently sharing a hashtable between processes on a local Unix machine.
|
98
|
+
test_files: []
|
99
|
+
|