浏览代码

idle support

David 10 年之前
父节点
当前提交
18c01e4ed2
共有 1 个文件被更改,包括 7 次插入2 次删除
  1. 7 2
      scripts/stats.py

+ 7 - 2
scripts/stats.py

@@ -11,6 +11,8 @@ CMDS = ['LOAD', 'CPU', 'BLOCK', 'UNBLOCK', 'EXIT', 'DEADLINE']
 def parseData(fin):
 def parseData(fin):
 	ln = 0
 	ln = 0
 	lastBlock = 0
 	lastBlock = 0
+	idle_counter = 0
+	last_idle_tick = -1
 	result = []
 	result = []
 
 
 	for l in fin:
 	for l in fin:
@@ -31,6 +33,9 @@ def parseData(fin):
 
 
 		# Ignoro a idle
 		# Ignoro a idle
 		if proceso == -1:
 		if proceso == -1:
+			if tick > last_idle_tick: #no quiero contar multiples idle ticks en el mismo ciclo
+				idle_counter+=1
+				last_idle_tick=tick
 			continue
 			continue
 		
 		
 		# Empiezo a contar cuando carga un proceso
 		# Empiezo a contar cuando carga un proceso
@@ -59,7 +64,7 @@ def parseData(fin):
 		if accion == 'EXIT':
 		if accion == 'EXIT':
 			result[proceso]['ultimoTick'] = tick
 			result[proceso]['ultimoTick'] = tick
 
 
-	return result
+	return (result, idle_counter)
 
 
 def main(argv):
 def main(argv):
 	if len(argv) <= 1:
 	if len(argv) <= 1:
@@ -67,7 +72,7 @@ def main(argv):
 	else:
 	else:
 		return 1
 		return 1
 
 
-	data = parseData(fin)
+	(data,idle) = parseData(fin)
 	print(json.dumps(data))
 	print(json.dumps(data))
 	return 0
 	return 0