forked from Netflix/falcor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
some updates of the program to handle performance testing.
- Loading branch information
1 parent
533f6b2
commit 2d80e01
Showing
12 changed files
with
141 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
var Rx = require('rx'); | ||
var RequestQueue = require('./RequestQueue'); | ||
var RequestQueueV2 = require('./RequestQueueV2'); | ||
|
||
function RequestQueueRx(model, scheduler) { | ||
this.model = model; | ||
this.scheduler = scheduler; | ||
this.requests = this._requests = []; | ||
} | ||
|
||
// RX MONKEY PATCH | ||
var getRequest = RequestQueueV2.prototype.get; | ||
RequestQueueRx.prototype.get = function(paths) { | ||
debugger | ||
var self = this; | ||
return Rx.Observable.create(function(observer) { | ||
debugger | ||
getRequest.call(self, paths, paths, function() { | ||
observer.onNext(); | ||
observer.onCompleted(); | ||
}); | ||
}); | ||
}; | ||
|
||
RequestQueueRx.prototype.set = RequestQueue.prototype.set; | ||
RequestQueueRx.prototype.call = RequestQueue.prototype.call; | ||
RequestQueueRx.prototype.removeRequest = RequestQueueV2.prototype.removeRequest; | ||
|
||
module.exports = RequestQueueRx; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var Rx = require('rx'); | ||
var TriggerDataSource = function TriggerDataSource(response) { | ||
this.response = response; | ||
this._triggers = []; | ||
}; | ||
|
||
TriggerDataSource.prototype = { | ||
get: function(paths) { | ||
var self = this; | ||
return Rx.Observable.create(function(observer) { | ||
self._triggers.push(function() { | ||
observer.onNext(self.response); | ||
observer.onCompleted(); | ||
}); | ||
}); | ||
}, | ||
trigger: function() { | ||
this._triggers.forEach(function(t) { | ||
t(); | ||
}); | ||
this._triggers = []; | ||
} | ||
}; | ||
|
||
module.exports = TriggerDataSource; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
var Model = require('./../../../lib').Model; | ||
var simple = [['videos', 1234, 'summary']]; | ||
var noOp = function() {}; | ||
var RequestQueueV2 = require('./../../../lib/request/RequestQueueV2'); | ||
var RequestQueue = require('./../../../lib/request/RequestQueue'); | ||
var ImmediateScheduler = require('./../../../lib/schedulers/ImmediateScheduler'); | ||
|
||
var TriggerDataSource = require('./../../TriggerDataSource'); | ||
var triggerSource = new TriggerDataSource({ | ||
jsonGraph: { | ||
videos: { | ||
1234: { | ||
summary: 'Test' | ||
} | ||
} | ||
} | ||
}); | ||
var triggerModel = new Model({ | ||
source: triggerSource | ||
}); | ||
var triggerQV2 = new RequestQueueV2(triggerModel, new ImmediateScheduler()); | ||
var triggerQ = new RequestQueue(triggerModel, new ImmediateScheduler()); | ||
|
||
module.exports = { | ||
name: 'RequestQueue', | ||
tests: { | ||
'RequestQueueV2.get#Simple Path': function(done) { | ||
triggerQV2.get(simple, simple, function() { | ||
}); | ||
triggerSource.trigger(); | ||
}, | ||
|
||
'RequestQueue(OLD).get#Simple Path': function(done) { | ||
triggerQ.get(simple).subscribe(noOp, noOp, function() { | ||
}); | ||
triggerSource.trigger(); | ||
}, | ||
|
||
'RequestQueueV2.batch-and-dedupe#Simple Path': function(done) { | ||
triggerQV2.get(simple, simple, function() { }); | ||
triggerQV2.get(simple, simple, function() { }); | ||
triggerSource.trigger(); | ||
}, | ||
|
||
'RequestQueue(OLD).batch-and-dedupe#Simple Path': function(done) { | ||
triggerQ.get(simple).subscribe(noOp, noOp, function() { }); | ||
triggerQ.get(simple).subscribe(noOp, noOp, function() { }); | ||
triggerSource.trigger(); | ||
} | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var Model = require('./lib').Model; | ||
var simple = [['videos', 1234, 'summary']]; | ||
var noOp = function() {}; | ||
var RequestQueueV2 = require('./lib/request/RequestQueueV2'); | ||
var ImmediateScheduler = require('./lib/schedulers/ImmediateScheduler'); | ||
var TriggerDataSource = require('./performance/TriggerDataSource'); | ||
var triggerSource = new TriggerDataSource({ | ||
jsonGraph: { | ||
videos: { | ||
1234: { | ||
summary: 'Test' | ||
} | ||
} | ||
} | ||
}); | ||
var triggerModel = new Model({ | ||
source: triggerSource | ||
}); | ||
var triggerQV2 = new RequestQueueV2(triggerModel, new ImmediateScheduler()); | ||
|
||
for (var i = 0; i < 200000; ++i) { | ||
triggerQV2.get(simple, simple, function() { }); | ||
triggerQV2.get(simple, simple, function() { }); | ||
triggerSource.trigger(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters