]> rtime.felk.cvut.cz Git - eurobot/public.git/commitdiff
timing: matlab scripts
authorMartin Zidek <zidekm1@gmail.com>
Tue, 19 May 2009 08:54:25 +0000 (10:54 +0200)
committerMartin Zidek <zidekm1@gmail.com>
Tue, 19 May 2009 08:54:25 +0000 (10:54 +0200)
src/timing/analyse.m [new file with mode: 0644]
src/timing/ftrace.m [new file with mode: 0644]

diff --git a/src/timing/analyse.m b/src/timing/analyse.m
new file mode 100644 (file)
index 0000000..ee85ae3
--- /dev/null
@@ -0,0 +1,39 @@
+file_app = fopen('trace.txt','r');
+
+if file_app == -1
+       error('File trace.txt cannot be opened for reading!');
+end
+
+for i=1:1
+    readin = fgetl(file_app);
+end
+
+i = 1;
+timestamps=zeros(5,2);
+
+while 1
+    readin = fgetl(file_app);
+    a = textscan(readin, '%d %n','delimiter',':');
+    if(a{1,1} == 0)
+        break;
+    end
+    timestamps(i, 1) = a{1, 1};
+    timestamps(i, 2) = (a{1,2});
+    i=i+1;
+end 
+
+timestamps_nr=size(timestamps,1);
+
+timestamps_diff=zeros(timestamps_nr/2,1);
+
+starts=zeros(timestamps_nr/2,1);
+ends=zeros(timestamps_nr/2,1);
+i=2;
+for j=1:timestamps_nr/2
+    timestamps_diff(j) = timestamps(i,2) - timestamps(i-1,2);
+    i = i + 2;
+end
+
+timestamps_diff = timestamps_diff.*1000000;
+
+fclose(file_app);
\ No newline at end of file
diff --git a/src/timing/ftrace.m b/src/timing/ftrace.m
new file mode 100644 (file)
index 0000000..a8d1b3a
--- /dev/null
@@ -0,0 +1,24 @@
+file_tswitch = fopen('taskswitch.log','r');
+
+if file_tswitch == -1
+       error('File trace.txt cannot be opened for reading!');
+end
+
+for i=1:4
+    readin = fgetl(file_tswitch);
+end
+
+
+while 1
+    readin = fgetl(file_tswitch);
+    if(readin == -1)
+        break;
+    end
+    line = regexpi(readin,'-(\d*)\s*\[000\]\s*(\d*.\d*):\s*(\d*):(\d*):(\w|?)\s*([=>+]*)\s\[000\]\s*(\d*):(\d*):(\w|?)','tokens')
+    fields = {'task','tstamp','pid','kernel_prio','task_state','action','pid_to','kernel_prio_to','task_state_to'}
+    line
+    %struct = cell2struct(line,fields,1);
+    i=i+1;
+end 
+
+fclose(file_tswitch);
\ No newline at end of file