Permalink
Browse files

Link traversal stuff, also fix function name in js

  • Loading branch information...
1 parent a6455c2 commit befb9e5cd98952c004a42a780e4be0f24e3d3b95 @lstoll committed Feb 19, 2010
Showing with 127 additions and 1 deletion.
  1. +115 −0 4_perf_tests/3_link_traversal.rb
  2. +11 −0 4_perf_tests/3_link_traversal.rb.out.txt
  3. +1 −1 4_perf_tests/5_cached.js
@@ -0,0 +1,115 @@
+require 'riak'
+require '../lib/utils.rb'
+
+# Connect and get a bucket instance
+client = Riak::Client.new
+bucket = client.bucket("test4", :keys => false) # we don't want to load all the keys!
+
+time "Traverse 1 links" do
+ # Grab a starting point, and walk
+ obj = bucket.get('1000')
+
+ p obj.walk(:bucket => bucket.name, :tag => 'parent')
+end
+
+time "Traverse 5 links" do
+ # Grab a starting point, and walk
+ obj = bucket.get('15000')
+
+ # One doesn't do it like this, because you can't (seemingly) run link-only queries
+ #puts Riak::MapReduce.new(client).add(bucket.name).
+ # link(:tag => 'parent').
+ # link(:tag => 'parent', :keep => true).run
+
+ # Instead, like this. Neato, can just keep adding them
+ p obj.walk(:bucket => bucket.name, :tag => 'parent')
+
+ # Could build this easier, but want to make a point.
+ p obj.walk({:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'})
+end
+
+time "Traverse 10 links" do
+ # Grab a starting point, and walk
+ obj = bucket.get('10000')
+
+ p obj.walk({:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'})
+end
+
+time "Traverse 50 links" do
+ # Grab a starting point, and walk
+ obj = bucket.get('5000')
+
+ # One doesn't do it like this, because you can't (seemingly) run link-only queries
+ #puts Riak::MapReduce.new(client).add(bucket.name).
+ # link(:tag => 'parent').
+ # link(:tag => 'parent', :keep => true).run
+
+ # Instead, like this. Neato, can just keep adding them
+ p obj.walk(:bucket => bucket.name, :tag => 'parent')
+
+ # Could build this easier, but want to make a point.
+ p obj.walk({:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'},
+ {:bucket => bucket.name, :tag => 'parent'})
+end
+
@@ -0,0 +1,11 @@
+[[#<Riak::RObject http://127.0.0.1:8098/raw/test4/999 [application/javascript]:"{\"item\":\"one\",\"batch\":99}">]]
+Traverse 1 links execution time: 0.180818s
+[[#<Riak::RObject http://127.0.0.1:8098/raw/test4/14999 [application/javascript]:"{\"item\":\"one\",\"batch\":1499}">]]
+[[#<Riak::RObject http://127.0.0.1:8098/raw/test4/14995 [application/javascript]:"{\"item\":\"one\",\"batch\":1499}">]]
+Traverse 5 links execution time: 0.340732s
+[[#<Riak::RObject http://127.0.0.1:8098/raw/test4/9990 [application/javascript]:"{\"item\":\"one\",\"batch\":999}">]]
+Traverse 10 links execution time: 0.547865s
+[[#<Riak::RObject http://127.0.0.1:8098/raw/test4/4999 [application/javascript]:"{\"item\":\"one\",\"batch\":499}">]]
+[[#<Riak::RObject http://127.0.0.1:8098/raw/test4/4950 [application/javascript]:"{\"item\":\"one\",\"batch\":495}">]]
+Traverse 50 links execution time: 0.695869s
+
View
@@ -1,4 +1,4 @@
-function FourSixCachedTest(v) {
+function FourFiveCachedTest(v) {
// Load the items data, and parse it
obj = JSON.parse(v.values[0].data);
if (obj.batch && obj.batch == '513') {

0 comments on commit befb9e5

Please sign in to comment.