Skip to content
This repository has been archived by the owner on Dec 31, 2020. It is now read-only.

Commit

Permalink
Add speed tests for repeated projection calls
Browse files Browse the repository at this point in the history
  • Loading branch information
alexnault committed May 22, 2015
1 parent 4530270 commit 23f6040
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,21 @@ describe('Projection', function(){
done();
});
})

it('should return theaters more quickly the second time', function(done){
var start = new Date().getTime();

p.findTheaters('Montreal', {}, function(err, theaters) {
var t1 = new Date().getTime() - start;
start = new Date().getTime();
p.findTheaters('Montreal', {}, function(err, theaters) {
var t2 = new Date().getTime() - start;
assert(t1 >= t2); // ~500ms to ~10ms
assert(t2 < 100); // Expect cache to take lesser than 100ms
done();
});
});
})
})

// Expected JSON format
Expand Down Expand Up @@ -96,5 +111,20 @@ describe('Projection', function(){
done();
});
})

it('should return a movie more quickly the second time', function(done){
var start = new Date().getTime();

p.findMovie('Montreal', 'Mad Max', {}, function(err, theaters) {
var t1 = new Date().getTime() - start;
start = new Date().getTime();
p.findMovie('Montreal', 'Mad Max', {}, function(err, theaters) {
var t2 = new Date().getTime() - start;
assert(t1 >= t2); // ~500ms to ~10ms
assert(t2 < 100); // Expect cache to take lesser than 100ms
done();
});
});
})
})
})

0 comments on commit 23f6040

Please sign in to comment.