-
Notifications
You must be signed in to change notification settings - Fork 0
/
mem.html
120 lines (116 loc) · 4.89 KB
/
mem.html
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Node Memory</title>
<script src="jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.3/jquery-ui.min.js"></script>
<script src="public/js/Chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.3.0/knockout-min.js"></script>
</head>
<body>
<canvas id="myChart" width="1000" height="400"></canvas>
<br>
<input type="checkbox" checked name="active" id="active"><label for="active">Active</label><br>
<button type="button" id="clearGraph">Clear</button>
<div id="legend">
<div>Active requests:<span id="ar"></span></div>
</div>
<script>
$(document).ready(function(){
$('#clearGraph').click(function(){
chart.clear();
});
var chart;
var chartOpts = {
pointDot: false,
datasetStrokeWidth: 1,
animation: false,
scaleShowVerticalLines: false,
legendTemplate: '<ul>'
+ '<% for (var i=0; i<datasets.length; i++) { %>'
+ '<li>'
+ '<span style=\"background-color:<%=datasets[i].lineColor%>\"></span>'
+ '<% if (datasets[i].label) { %><%= datasets[i].label %><% } %>'
+ '</li>'
+ '<% } %>'
+ '</ul>'
};
var data = {
labels: [],
datasets: [
{
label: "Rss",
fillColor: "rgba(255,220,220,0)",
strokeColor: "rgba(255,0,0,1)",
pointColor: "rgba(255,0,0,1)",
lineColor: "rgba(255,0,0,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: []
},
{
label: "HeapTotal",
fillColor: "rgba(220,220,220,0)",
strokeColor: "rgba(0,255,0,1)",
pointColor: "rgba(0,255,0,1)",
lineColor: "rgba(0,255,0,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: []
},
{
label: "HeapUsed",
fillColor: "rgba(220,220,220,0)",
strokeColor: "rgba(0,0,255,1)",
pointColor: "rgba(0,0,255,1)",
lineColor: "rgba(0,0,255,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: []
},
{
label: "ResponseTime",
fillColor: "rgba(220,220,220,0)",
strokeColor: "rgba(0,0,0,1)",
pointColor: "rgba(0,0,0,1)",
lineColor: "rgba(0,0,0,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(220,220,220,1)",
data: []
}
]
};
var ctx = document.getElementById("myChart").getContext("2d");
chart = new Chart(ctx).Line(data, chartOpts);
// var legend = chart.generateLegend();
// console.log(legend); //TODO: Remove
$('#legend').append('<div style="background-color: rgba(255,0,0,1)">RSS: <span id="rss"></span> Mb</div>');
$('#legend').append('<div style="background-color: rgba(0,255,0,1)">HeapTotal: <span id="ht"></span> Mb</div>');
$('#legend').append('<div style="background-color: rgba(0,0,255,1); color: #fff;">HeapUsed: <span id="hu"></span> Mb</div>');
$('#legend').append('<div style="background-color: rgba(0,0,0,1); color: #fff;">ResponseTime: <span id="rt"></span> cs</div>');
count = 0;
setInterval(function(){
if(document.getElementById('active').checked){
var start = new Date().getTime();
$('#ar').text($.active);
console.log('get data'); //TODO: Remove
$.get('https://group-app-load-test.herokuapp.com/profiles/verify2', function(data){
console.log(data); //TODO: Remove
var total = (new Date().getTime() - start) / 10;
$('#rss').text(Math.floor(data.rss / 1024 / 1024));
$('#ht').text(Math.floor(data.heapTotal / 1024 / 1024));
$('#hu').text(Math.floor(data.heapUsed / 1024 / 1024));
$('#rt').text(total);
chart.addData([data.rss / 1024 / 1024, data.heapTotal / 1024 / 1024, data.heapUsed / 1024 / 1024, total], count++)
});
}
}, 1000);
});
</script>
</body>
</html>