Skip to content
Browse files

Add benchmark

  • Loading branch information...
1 parent f22e28b commit 21c32c9d8c8d8ffa36c832879a9d432abd677df2 @vesln vesln committed
Showing with 67 additions and 0 deletions.
  1. +67 −0 benchmark/crud.js
View
67 benchmark/crud.js
@@ -0,0 +1,67 @@
+var Seed = require('seed')
+ , RiakStore = require('..');
+
+suite('CRUD Operations', function () {
+ set('type', 'static');
+ set('iterations', 50000);
+ set('silent', true);
+
+ var UID = new Seed.Flake()
+ , keystore = []
+ , store = new RiakStore();
+
+ var Rand = Seed.Model.extend('crud', {
+ store: store
+ });
+
+ bench('create', function (next) {
+ var uid = UID.gen()
+ , model = new Rand({
+ _id: uid
+ });
+ keystore.push(uid);
+ model.save(function (ex) {
+ if (ex) throw ex;
+ next();
+ });
+ });
+
+ var readpos = 0;
+ bench('read', function (next) {
+ var uid = keystore[readpos]
+ , model = new Rand({
+ _id: uid
+ });
+ readpos++;
+ model.fetch(function (ex) {
+ if (ex) throw ex;
+ next();
+ });
+ });
+
+ var updatepos = 0;
+ bench('update', function (next) {
+ var uid = keystore[updatepos]
+ , model = new Rand({
+ _id: uid
+ , hello: 'world'
+ });
+ updatepos++;
+ model.save(function (ex) {
+ if (ex) throw ex;
+ next();
+ });
+ });
+
+ var delpos = 0;
+ bench('destroy', function (next) {
+ var uid = keystore[delpos]
+ , model = new Rand({
+ _id: uid
+ });
+ model.destroy(function (ex) {
+ if (ex) throw ex;
+ next();
+ });
+ });
+});

0 comments on commit 21c32c9

Please sign in to comment.
Something went wrong with that request. Please try again.