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 04/12] trace-cruncher: Add "utils"
Date: Tue, 7 Jan 2020 19:03:04 +0200 [thread overview]
Message-ID: <20200107170312.27116-5-y.karadz@gmail.com> (raw)
In-Reply-To: <20200107170312.27116-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
next prev 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 ` Yordan Karadzhov (VMware) [this message]
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 ` [PATCH v2 07/12] trace-cruncher: Adapt gpareto_fit.py to use the new module Yordan Karadzhov (VMware)
2020-01-07 17:03 ` [PATCH v2 08/12] trace-cruncher: Adapt page_faults.py " 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-5-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).