-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodos-load-test.js
45 lines (41 loc) · 1.26 KB
/
todos-load-test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// MeteorDown Script
mdown.init(function (Meteor) {
var i = 0;
Meteor.subscribe('publicLists', function () {
//console.log('publiLists is ready');
//console.log(Meteor.collections.lists);
Meteor.subscribe("todos","nt7QzdfcwfwzDRfEs", function() {
var o = Meteor.collections.todos;
var keys = Object.keys(o);
//console.log(keys);
var todos_length = keys.length;
//console.log(todos_length);
var randomN = Math.floor((Math.random() * (todos_length-1)) + 0);
//console.log(randomN);
var randomKey = keys[randomN];
//console.log(randomKey);
//console.log(Meteor.collections.todos);
setTimeout(function() {
if(Meteor.collections.todos[randomKey].checked){
Meteor.call("/todos/update", {"_id":randomKey}, {"$set":{"checked":false}}, function (err, res) {
//console.log("Updated to false")
});
}else{
Meteor.call("/todos/update", {"_id":randomKey}, {"$set":{"checked":true}}, function (err, res) {
//console.log("Updated to true")
});
}
setTimeout(function() {
Meteor.kill();
},1000);
}, 1000);
});
});
//method":"/todos/update","params":[{"_id":"Zn2RPhbFEqidhpwFf"},{"$set":{"checked":false}}
});
mdown.run({
concurrency: 50,
url: 'http://localhost:3000',
key: undefined,
auth: undefined
});