Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Allow plotting wall clock time on x-axis. #69

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import numpy as np
import matplotlib
import datetime

import matplotlib.pyplot as plt

Expand All @@ -25,7 +26,7 @@ def save(fig, legend, fileName, fileFormat='pdf', overwrite=False):
fig.savefig(fullFileName, bbox_inches='tight', format=fileFormat)


def plotMultiDelays(x, delays, xLabel, labels=None, title=None, markersize=1.5, fileName=None, overwrite=None, colors=None, block=False, show=False):
def plotMultiDelays(x, delays, xLabel, labels=None, title=None, markersize=1.5, fileName=None, overwrite=None, colors=None, block=False, show=False, wallclock=False):
if not colors:
defaultColors = ['r', 'g', 'b']
colors = list(reversed(defaultColors[:len(delays)]))
Expand All @@ -39,8 +40,11 @@ def plotMultiDelays(x, delays, xLabel, labels=None, title=None, markersize=1.5,
breakX = False

def plotMyDelays(ax):
xA = np.array(x, dtype=float)
xA = xA - min(xA[~np.isnan(xA)])
if wallclock:
xA = np.array([datetime.datetime.fromtimestamp(b) for b in x], dtype='datetime64')
else:
xA = np.array(x, dtype=float)
xA = xA - xA[~np.isnan(xA)].min()
if labels:
for i, (d, l) in enumerate(zip(delays, labels)):
assert(len(xA) == len(d))
Expand Down
3 changes: 2 additions & 1 deletion cuckoo_time_translator_python/scripts/ctt_introspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
parser.add_argument('--invalidate', action='store_true', help='invalidate any possibly existing cache')
parser.add_argument('--showDefaults', action='store_true', help='Show all parameters in the legend even if they are at their default value')
parser.add_argument('--force', action='store_true', help='Force overwriting')
parser.add_argument('--wallclock', action='store_true', help='Show wall clock time on x-axis')

args = parser.parse_args()
verbosity = args.verbose
Expand Down Expand Up @@ -97,7 +98,7 @@ def addToPlot(times, label, color):
printDelayStat(d, lab)

from cuckoo_time_translator_python.plotting import plotMultiDelays, show
plotMultiDelays(base_times, delaysToPlot, "time [sec]", labels, markersize=4, colors=colors, fileName=args.output, overwrite=args.force, show=False)
plotMultiDelays(base_times, delaysToPlot, "time [sec]", labels, markersize=4, colors=colors, fileName=args.output, overwrite=args.force, show=False, wallclock=args.wallclock)

if not args.output:
from cuckoo_time_translator_python.plotting import show
Expand Down