-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
100 lines (79 loc) · 2.22 KB
/
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Lists -- {name: String}
Lists = new Meteor.Collection("lists");
var listsHandle = null;
var now = function()
{
return (new Date()).getTime();
}
var clearDb = function() {
Lists.remove({});
}
var fillDb = function() {
var hoursCount = 365 * 24;
var metricsCount = 100;
var oldTime = now();
var vals = [];
for (var j = 0; j<60; j++) {
vals[j] = j;
}
for (var i = 0; i<hoursCount; i++) {
var query = []
for (var k = 0; k<metricsCount; k++) {
var id = "" + (i*1000 + k);
//console.log(id);
var val = Lists.findOne({ _id:id });
if( val === undefined)
Lists.insert( { _id:id, ticks:i, metric:k, samples:[] } );
query.push(id);
//Lists.update( { _id:id} , {$push : {samples: {$each : vals} } } );
for (var j = 0; j<60; j++) {
Lists.update( { _id:id} , {$push : {samples:j} } );
}
/*
val = Lists.findOne({ _id:id });
for (var j = 0; j<60; j++) {
val.samples[j] = j;
var samples = val.samples;
Lists.update( { _id:id} , {$set : {samples:samples} } );
}
*/
}
//Lists.update( { _id:{$in:query} } , {$push : {samples: {$each : vals} } } );
if((i%24) == 0)
{
var deltaTime = now() - oldTime;
console.log("d = ", i / 24, " / ", hoursCount / 24, " in ", deltaTime, " ms");
var val = Lists.findOne();
//console.log(val);
oldTime = now();
}
}
var deltaTime = now() - oldTime;
console.log(">> deltaTime = ", deltaTime);
}
if (Meteor.isClient) {
var listsHandle = Meteor.subscribe('lists', function () {});
Template.hello.greeting = function () {
return "Welcome to test.";
};
Template.hello.events({
'click input' : function () {
// template data, if any, is available in 'this'
if (typeof console !== 'undefined')
console.log("You pressed the button");
}
});
}
if (Meteor.isServer) {
Meteor.startup(function () {
clearDb();
fillDb();
// code to run on server at startup
});
/*
// Publish complete set of lists to all clients.
Meteor.publish('lists', function () {
return Lists.find();
});
*/
}