changeset 1431:9b0908cb7553 draft

change to exporting filetype
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Fri, 30 Mar 2012 05:51:29 +0900
parents f578c190a661
children b77f32eb137c
files TaskManager/kernel/ppe/ExportTaskLog.cc TaskManager/kernel/ppe/TaskLog.h scripts/log.rb scripts/view_log.sh
diffstat 4 files changed, 48 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/TaskManager/kernel/ppe/ExportTaskLog.cc	Wed Mar 28 17:50:03 2012 +0900
+++ b/TaskManager/kernel/ppe/ExportTaskLog.cc	Fri Mar 30 05:51:29 2012 +0900
@@ -1,5 +1,5 @@
 #include "ExportTaskLog.h"
-const char* const ExportTaskLog::FILENAME="logfile.xml";
+const char* const ExportTaskLog::FILENAME="logfile.yml";
 
 ExportTaskLog::ExportTaskLog(QueueInfo<TaskLog> *_tasklog)
 {
@@ -25,25 +25,22 @@
 void
 ExportTaskLog::printOut()
 {
-    fprintf(fp, "<root>\n");
     while(!tasklog->empty()){
         TaskLog *log = tasklog->poll();
-        fprintf(fp, "<task>\n");
-        fprintf(fp, "\t<task_id>%d</task_id>\n", log->mtask_id);
-        fprintf(fp, "\t<cmd>%d</cmd>\n", log->cmd);
-        fprintf(fp, "\t<create_time>%llu</create_time>\n", log->create_time);
-        fprintf(fp, "\t<execute_time>%llu</execute_time>\n", log->execute_time);
-        fprintf(fp, "\t<finish_time>%llu</finish_time>\n", log->finish_time);
+        fprintf(fp, "--- \n");
+        fprintf(fp, "task_id:      %d\n", log->mtask_id);
+        fprintf(fp, "cmd:          %d\n", log->cmd);
+        fprintf(fp, "create_time:  %llu\n", log->create_time);
+        fprintf(fp, "execute_time: %llu\n", log->execute_time);
+        fprintf(fp, "finish_time:  %llu\n", log->finish_time);
+        fprintf(fp, "wait_for:\n");
         while(!log->wait_for_list.empty()){
             waitTask *task = log->wait_for_list.poll();
-            fprintf(fp, "\t<wait_for>\n");
-            fprintf(fp, "\t\t<task_id>%d</task_id>\n", task->task_id);
-            fprintf(fp, "\t\t<cmd>%d</cmd>\n", task->cmd);
-            fprintf(fp, "\t</wait_for>\n");
+            fprintf(fp, "  - \n");
+            fprintf(fp, "    task_id: %d\n", task->task_id);
+            fprintf(fp, "    cmd:     %d\n", task->cmd);
         }
-        fprintf(fp, "</task>\n");
     }
-    fprintf(fp, "</root>\n");
 }
 
 void
--- a/TaskManager/kernel/ppe/TaskLog.h	Wed Mar 28 17:50:03 2012 +0900
+++ b/TaskManager/kernel/ppe/TaskLog.h	Fri Mar 30 05:51:29 2012 +0900
@@ -31,6 +31,9 @@
     TaskLog() {
         mtask_id = task_id;
         task_id++;
+        create_time = 0;
+        execute_time = 0;
+        finish_time = 0;
     }
 
     void set_cmd(int _cmd) {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/log.rb	Fri Mar 30 05:51:29 2012 +0900
@@ -0,0 +1,27 @@
+require 'yaml'
+log_file = ARGV[0]
+
+puts 'digraph log {'
+puts 'node [shape = record];'
+YAML.load_documents(open(log_file)) do |doc|
+  print doc['task_id'].to_s
+  print '['
+  print 'label = "{'
+  print doc['task_id'].to_s + '|'
+  print 'cmd:\ ' + doc['cmd'].to_s + '\l' + '\n'
+  print 'create:\ ' + doc['create_time'].to_s + '\l' + '\n'
+  print 'execute:\ ' + doc['execute_time'].to_s + '\l' + '\n'
+  print 'finish:\ ' + doc['finish_time'].to_s + '\l' + '\n'
+  print '}"];' + "\n"
+end
+
+YAML.load_documents(open(log_file)) do |doc|
+  if doc['wait_for'] != nil then
+    doc['wait_for'].each do |task|
+      puts task['task_id'].to_s + ' -> ' + doc['task_id'].to_s
+    end
+  end
+
+end
+
+puts '}'
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/scripts/view_log.sh	Fri Mar 30 05:51:29 2012 +0900
@@ -0,0 +1,7 @@
+#!/bin/bash
+if [ $# -ne 1 ]; then
+    echo "usage: ./view_log.sh target"
+    exit 1
+fi
+ruby ./log.rb $1 > /tmp/log.dot
+dot -Tsvg /tmp/log.dot > /tmp/log.svg; open /tmp/log.svg