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, Douglas.Raillard@arm.com,
	Valentin.Schneider@arm.com, nd@arm.com,
	"Yordan Karadzhov (VMware)" <y.karadz@gmail.com>
Subject: [PATCH v2 07/12] trace-cruncher: Adapt gpareto_fit.py to use the new module
Date: Tue,  7 Jan 2020 19:03:07 +0200	[thread overview]
Message-ID: <20200107170312.27116-8-y.karadz@gmail.com> (raw)
In-Reply-To: <20200107170312.27116-1-y.karadz@gmail.com>

The patch contains some debugging as well.

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

diff --git a/examples/gpareto_fit.py b/examples/gpareto_fit.py
index 4a2bb2a..eece064 100755
--- a/examples/gpareto_fit.py
+++ b/examples/gpareto_fit.py
@@ -16,11 +16,10 @@ import numpy as np
 from scipy.stats import genpareto as gpareto
 from scipy.optimize import curve_fit as cfit
 
-from ksharksetup import setup
-# Always call setup() before importing ksharkpy!!!
-setup()
-
-import ksharkpy as ks
+import tracecruncher.datawrapper as dw
+import tracecruncher.ksharkpy as ks
+import tracecruncher.ftracepy as ft
+import tracecruncher.utils as tc
 
 def chi2_test(hist, n_bins, c, loc, scale, norm):
     """ Simple Chi^2 test for the goodness of the fit.
@@ -92,7 +91,7 @@ def get_cpu_data(data, task_pid, start_id, stop_id, threshold):
         than the specified threshold.
     """
     # Get the size of the data.
-    size = ks.data_size(data)
+    size = tc.size(data)
     #print("data size:", size)
 
     time_start = -1
@@ -130,7 +129,7 @@ def make_ks_session(fname, data, start, stop):
         The sessions is zooming around the maximum observed latency.
     """
     sname = 'max_lat.json'
-    ks.new_session(fname, sname)
+    tc.new_gui_session(fname, sname)
     i_start = int(start)
     i_stop = int(stop)
 
@@ -145,28 +144,28 @@ def make_ks_session(fname, data, start, stop):
         session['Model']['range'] = [tmin, tmax]
 
         session['Markers']['markA']['isSet'] = True
-        session['Markers']['markA']['row'] = i_start)
+        session['Markers']['markA']['row'] = i_start
 
         session['Markers']['markB']['isSet'] = True
-        session['Markers']['markB']['row'] = i_stop)
+        session['Markers']['markB']['row'] = i_stop
 
-        session['ViewTop'] = i_start) - 5
+        session['ViewTop'] = i_start - 5
 
-        ks.save_session(session, s)
+        tc.save_session(session, s)
 
 
 fname = str(sys.argv[1])
-status = ks.open_file(fname)
+status = ks.open(fname)
 if not status:
     print ("Failed to open file ", fname)
     sys.exit()
 
 ks.register_plugin('reg_pid')
-data = ks.load_data()
+data = dw.load()
 
 # Get the Event Ids of the hrtimer_start and print events.
-start_id = ks.event_id('timer', 'hrtimer_start')
-stop_id = ks.event_id('ftrace', 'print')
+start_id = ft.event_id('timer', 'hrtimer_start')
+stop_id = ft.event_id('ftrace', 'print')
 print("start_id", start_id)
 print("stop_id", stop_id)
 
@@ -194,9 +193,6 @@ ks.close()
 dt_ot = np.array(data_ot)
 np.savetxt('peak_over_threshold_loaded.txt', dt_ot)
 
-make_ks_session(fname=fname, data=data, i_start=int(dt_ot[i_max_lat][1]),
-                                        i_stop=int(dt_ot[i_max_lat][2]))
-
 P = len(dt_ot) / tot
 err_P = error_P(n=len(dt_ot), N=tot)
 print('tot:', tot, ' P =', P)
@@ -208,6 +204,9 @@ print('imax:', i_max_lat, int(dt_ot[i_max_lat][1]))
 
 print('max', np.amax(dt_ot))
 
+make_ks_session(fname=fname, data=data, start=dt_ot[i_max_lat][1],
+                                        stop=dt_ot[i_max_lat][2])
+
 start = threshold
 stop = 31
 n_bins = (stop - start) * 2
-- 
2.20.1


  parent reply	other threads:[~2020-01-07 17:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-07 17:03 [PATCH v2 00/12] Build trace-cruncher as Python pakage Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 01/12] trace-cruncher: Refactor the part of the interface that relies on libkshark Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 02/12] trace-cruncher: Refactor the part of the interface that relies on libtraceevent Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 03/12] trace-cruncher: Refactor NumPy based data wrapper Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 04/12] trace-cruncher: Add "utils" Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 05/12] trace-cruncher: Adapt sched_wakeup.py to use the new module Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 06/12] trace-cruncher: Add Makefile Yordan Karadzhov (VMware)
2020-01-07 17:03 ` Yordan Karadzhov (VMware) [this message]
2020-01-07 17:03 ` [PATCH v2 08/12] trace-cruncher: Adapt page_faults.py to use the new module Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 09/12] trace-cruncher: Automate the third-party build Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 10/12] trace-cruncher: Update README.md Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 11/12] trace-cruncher: Remove all leftover files Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 12/12] trace-cruncher: Improve Makefile Provide more robust and better looking build process 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=20200107170312.27116-8-y.karadz@gmail.com \
    --to=y.karadz@gmail.com \
    --cc=Douglas.Raillard@arm.com \
    --cc=Valentin.Schneider@arm.com \
    --cc=linux-trace-devel@vger.kernel.org \
    --cc=nd@arm.com \
    --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).