forked from cory/tildefriends
		
	Add some CPU and memory info to stats.
git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3820 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
		| @@ -484,12 +484,11 @@ function receive(message) { | ||||
| 			if (!gGraphs[key]) { | ||||
| 				var graph = { | ||||
| 					chart: new SmoothieChart({ | ||||
| 							millisPerPixel: 100, | ||||
| 							minValue: 0, | ||||
| 							grid: { | ||||
| 								strokeStyle: 'rgb(125, 0, 0)', | ||||
| 								fillStyle: 'rgb(60, 0, 0)', | ||||
| 								lineWidth: 1, | ||||
| 								millisPerLine: 15000, | ||||
| 								verticalSections: 6, | ||||
| 								millisPerLine: 1000, | ||||
| 								verticalSections: 10, | ||||
| 							}, | ||||
| 						}), | ||||
| 					canvas: document.createElement('canvas'), | ||||
| @@ -503,7 +502,7 @@ function receive(message) { | ||||
| 				document.getElementById('graphs').appendChild(div); | ||||
| 				document.getElementById('graphs').appendChild(graph.canvas); | ||||
| 				graph.chart.streamTo(graph.canvas, 1000); | ||||
| 				graph.chart.addTimeSeries(graph.timeseries); | ||||
| 				graph.chart.addTimeSeries(graph.timeseries, {lineWidth: 2}); | ||||
| 			} | ||||
| 			gGraphs[key].timeseries.append(now, message.stats[key]); | ||||
| 		} | ||||
|   | ||||
							
								
								
									
										16
									
								
								src/task.c
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								src/task.c
									
									
									
									
									
								
							| @@ -98,6 +98,7 @@ typedef struct _tf_task_t | ||||
| 	uv_timer_t trace_timer; | ||||
| 	uint64_t last_hrtime; | ||||
| 	uint64_t last_idle_time; | ||||
| 	float idle_percent; | ||||
|  | ||||
| 	uv_idle_t idle; | ||||
| 	uv_prepare_t prepare; | ||||
| @@ -721,6 +722,14 @@ static JSValue _tf_task_getStats(JSContext* context, JSValueConst this_val, int | ||||
| 	JS_SetPropertyStr(context, result, "import_count", JS_NewInt32(context, task->_import_count)); | ||||
| 	JS_SetPropertyStr(context, result, "export_count", JS_NewInt32(context, task->_export_count)); | ||||
| 	JS_SetPropertyStr(context, result, "promise_count", JS_NewInt32(context, task->_promise_count)); | ||||
|  | ||||
| 	JS_SetPropertyStr(context, result, "idle_percent", JS_NewFloat64(context, task->idle_percent)); | ||||
|  | ||||
| 	size_t rss; | ||||
| 	if (uv_resident_set_memory(&rss) == 0) | ||||
| 	{ | ||||
| 		JS_SetPropertyStr(context, result, "rss", JS_NewInt64(context, rss)); | ||||
| 	} | ||||
| 	return result; | ||||
| } | ||||
|  | ||||
| @@ -1277,6 +1286,9 @@ static void _tf_task_trace_timer(uv_timer_t* timer) | ||||
| 	tf_task_t* task = timer->data; | ||||
| 	uint64_t hrtime = uv_hrtime(); | ||||
| 	uint64_t idle_time = uv_metrics_idle_time(&task->_loop); | ||||
| 	task->idle_percent = (hrtime - task->last_hrtime) ? 100.0f * (idle_time - task->last_idle_time) / (hrtime - task->last_hrtime) : 0.0f; | ||||
| 	task->last_hrtime = hrtime; | ||||
| 	task->last_idle_time = idle_time; | ||||
| 	const char* k_names[] = | ||||
| 	{ | ||||
| 		"child_tasks", | ||||
| @@ -1291,10 +1303,8 @@ static void _tf_task_trace_timer(uv_timer_t* timer) | ||||
| 		task->_import_count, | ||||
| 		task->_export_count, | ||||
| 		task->_promise_count, | ||||
| 		(hrtime - task->last_hrtime) ? 100LL * (idle_time - task->last_idle_time) / (hrtime - task->last_hrtime) : 0, | ||||
| 		(int64_t)task->idle_percent, | ||||
| 	}; | ||||
| 	task->last_hrtime = hrtime; | ||||
| 	task->last_idle_time = idle_time; | ||||
| 	tf_trace_counter(task->_trace, "task", sizeof(k_names) / sizeof(*k_names), k_names, values); | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user