linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
To: linux-trace-devel@vger.kernel.org
Cc: rostedt@goodmis.org, Valentin.Schneider@arm.com,
	douglas.raillard@arm.com,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH 5/5] Adapt the sched_wakeup.py example script to use the new tracecruncher module
Date: Thu, 12 Dec 2019 11:02:32 +0200	[thread overview]
Message-ID: <20191212090232.24236-6-y.karadz@gmail.com> (raw)
In-Reply-To: <20191212090232.24236-1-y.karadz@gmail.com>

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 examples/sched_wakeup.py | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/examples/sched_wakeup.py b/examples/sched_wakeup.py
index 52f2688..41e0c9c 100755
--- a/examples/sched_wakeup.py
+++ b/examples/sched_wakeup.py
@@ -15,18 +15,18 @@ import matplotlib.pyplot as plt
 import scipy.stats as st
 import numpy as np
 
-from ksharksetup import setup
-# Always call setup() before importing ksharkpy!!!
-setup()
+import tracecruncher.datawrapper as dw
+import tracecruncher.ksharkpy as ks
+import tracecruncher.ftracepy as ft
+import tracecruncher.utils as tc
 
-import ksharkpy as ks
 # Get the name of the user program.
 if len(sys.argv) >= 2:
     fname = str(sys.argv[1])
 else:
     fname = input('choose a trace file: ')
 
-status = ks.open_file(fname)
+status = ks.open(fname)
 if not status:
     print ("Failed to open file ", fname)
     sys.exit()
@@ -35,7 +35,7 @@ ks.register_plugin('reg_pid')
 
 # We do not need the Process Ids of the records.
 # Do not load the "pid" data.
-data = ks.load_data(pid_data=False)
+data = dw.load(pid_data=False)
 tasks = ks.get_tasks()
 
 # Get the name of the user program.
@@ -48,8 +48,8 @@ else:
 task_pid = tasks[prog_name][0]
 
 # Get the Event Ids of the sched_switch and sched_waking events.
-ss_eid = ks.event_id('sched', 'sched_switch')
-w_eid = ks.event_id('sched', 'sched_waking')
+ss_eid = ft.event_id('sched', 'sched_switch')
+w_eid = ft.event_id('sched', 'sched_waking')
 
 # Gey the size of the data.
 i = data['offset'].size
@@ -60,7 +60,7 @@ delta_max = i_ss_max = i_sw_max = 0
 while i > 0:
     i = i - 1
     if data['event'][i] == ss_eid:
-        next_pid = ks.read_event_field(offset=data['offset'][i],
+        next_pid = ft.read_event_field(offset=data['offset'][i],
                                        event_id=ss_eid,
                                        field='next_pid')
 
@@ -77,9 +77,9 @@ while i > 0:
                         break
 
                 if data['event'][i] == ss_eid:
-                    next_pid = ks.read_event_field(offset=data['offset'][i],
-                                       event_id=ss_eid,
-                                       field='next_pid')
+                    next_pid = ft.read_event_field(offset=data['offset'][i],
+                                                   event_id=ss_eid,
+                                                   field='next_pid')
                     if next_pid == task_pid:
                         # Second sched_switch for the same task. ?
                         time_ss = data['time'][i]
@@ -89,7 +89,7 @@ while i > 0:
                     continue
 
                 if (data['event'][i] == w_eid):
-                    waking_pid = ks.read_event_field(offset=data['offset'][i],
+                    waking_pid = ft.read_event_field(offset=data['offset'][i],
                                                      event_id=w_eid,
                                                      field='pid')
 
@@ -120,7 +120,7 @@ ax.hist(dt, bins=(100), histtype='step')
 plt.show()
 
 sname = 'sched.json'
-ks.new_session(fname, sname)
+tc.new_gui_session(fname, sname)
 
 with open(sname, 'r+') as s:
     session = json.load(s)
@@ -143,6 +143,6 @@ with open(sname, 'r+') as s:
 
     session['ViewTop'] = int(i_sw_max) - 5
 
-    ks.save_session(session, s)
+    tc.save_session(session, s)
 
 ks.close()
-- 
2.20.1


  parent reply	other threads:[~2019-12-12  9:03 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-12  9:02 [PATCH 0/5] Build trace-cruncher as Python pakage Yordan Karadzhov (VMware)
2019-12-12  9:02 ` [PATCH 1/5] Refactor the part of the interface that relies on libkshark Yordan Karadzhov (VMware)
2019-12-12  9:02 ` [PATCH 2/5] Refactor the part of the interface that relies on libtraceevent Yordan Karadzhov (VMware)
2019-12-12  9:02 ` [PATCH 3/5] Refactor NumPy based data wrapper Yordan Karadzhov (VMware)
2019-12-12  9:02 ` [PATCH 4/5] Add "utils" Yordan Karadzhov (VMware)
2019-12-12  9:02 ` Yordan Karadzhov (VMware) [this message]
2019-12-31 18:37 ` [PATCH 0/5] Build trace-cruncher as Python pakage Douglas Raillard
2020-01-07 16:59   ` Yordan Karadzhov (VMware)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20191212090232.24236-6-y.karadz@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=Valentin.Schneider@arm.com \
    --cc=douglas.raillard@arm.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).