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 4/5] Add "utils"
Date: Thu, 12 Dec 2019 11:02:31 +0200	[thread overview]
Message-ID: <20191212090232.24236-5-y.karadz@gmail.com> (raw)
In-Reply-To: <20191212090232.24236-1-y.karadz@gmail.com>

Place the rest of the code, that is pure Python in tracecrunche/utils.py

Signed-off-by: Yordan Karadzhov (VMware) <y.karadz@gmail.com>
---
 tracecruncher/utils.py | 54 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 54 insertions(+)
 create mode 100644 tracecruncher/utils.py

diff --git a/tracecruncher/utils.py b/tracecruncher/utils.py
new file mode 100644
index 0000000..f785c01
--- /dev/null
+++ b/tracecruncher/utils.py
@@ -0,0 +1,54 @@
+"""
+SPDX-License-Identifier: LGPL-2.1
+
+Copyright 2019 VMware Inc, Yordan Karadzhov (VMware) <y.karadz@gmail.com>
+"""
+
+import json
+
+from . import datawrapper as dw
+from . import ksharkpy as ks
+
+def size(data):
+    """ Get the number of trace records.
+    """
+    for key in dw.data_column_types:
+        if data[key] is not None:
+            return data[key].size
+
+    raise Exception('Data size is unknown.')
+
+def save_session(session, s):
+    """ Save a KernelShark session description of a JSON file.
+    """
+    s.seek(0)
+    json.dump(session, s, indent=4)
+    s.truncate()
+
+
+def new_gui_session(fname, sname):
+    """ Generate and save a default KernelShark session description
+        file (JSON).
+    """
+    ks.new_session_file(fname, sname)
+
+    with open(sname, 'r+') as s:
+        session = json.load(s)
+
+        session['Filters']['filter mask'] = 7
+        session['CPUPlots'] = []
+        session['TaskPlots'] = []
+        session['Splitter'] = [1, 1]
+        session['MainWindow'] = [1200, 800]
+        session['ViewTop'] = 0
+        session['ColorScheme'] = 0.75
+        session['Model']['bins'] = 1000
+
+        session['Markers']['markA'] = {}
+        session['Markers']['markA']['isSet'] = False
+        session['Markers']['markB'] = {}
+        session['Markers']['markB']['isSet'] = False
+        session['Markers']['Active'] = 'A'
+
+        save_session(session, s)
+
-- 
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 ` Yordan Karadzhov (VMware) [this message]
2019-12-12  9:02 ` [PATCH 5/5] Adapt the sched_wakeup.py example script to use the new tracecruncher module Yordan Karadzhov (VMware)
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-5-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).