# Path: aqmt/processes.py
# def kill_known_pids():
# def add_known_pid(pid):
# def kill_pid(pid):
# def is_running(pid):
# def waitpid(pid):
# 
# Path: aqmt/plot/collectionutil.py
# def get_tree_details(tree):
#     def traverse(branch, depthnow=0):
# def get_gap(tree):
# def get_testcases(leaf):
# def get_all_testcases_folders(tree):
#     def parse_leaf(leaf, first_set, x):
# def make_xtics(tree, xoffset, x_axis):
#     def frange(start, stop, step):
# def get_testmeta_min_max_count(leaf, x_axis):
# def get_x_coordinate(leaf, value, x_axis):
# def merge_testcase_data_set_x(testcases, x_axis):
# def get_leaf_tests_stats(leaf, statsname):
# def merge_testcase_data(leaf, statsname, x_axis):
# def merge_testcase_data_group(leaf, statsname, x_axis):
# def get_xlabel(tree):
#     def fn(leaf, first_set, x):
# def pt_generator():
#     def get_val(tag):
# 
# Path: aqmt/plot/treeutil.py
# def get_depth_sizes(tree):
#     def check_node(item, x, depth):
# def walk_leaf(tree, fn):
#     def walk(branch):
# def walk_tree_reverse(tree, fn):
#     def walk(branch, depth=0):
# def walk_tree(tree, fn, include_leaf_collection=False):
#     def walk(collection, depth=0):
# def swap_levels(tree, level=0):
#         def walk(branch, depth):
#     def check_level(node, x, depth):
#     def build_swap(node, x, depth):
# def build_swap_list(level_order):
# def reorder_levels(tree, level_order=None):
# def skip_levels(tree, number_of_levels):
# 
# Path: aqmt/plot/common.py
# def add_plot(gpi):
#     """
#     Remove trailing comma from plot command because gnuplot complains about it
#     (We use the trailing comma to easier build plot commands)
#     """
#     return re.sub(r',(\s*\\?\s*\\?\s*)$', '\g<1>', gpi)
# 
# def add_scale(y_logarithmic, range_from=None, range_from_log=None,
#         range_to=None, range_to_log=None):
#     if y_logarithmic:
#         if range_from_log is None:
#             range_from_log = '1'
#         if range_to_log is None:
#             range_to_log = '*'
#         return """
#             set logscale y
#             set yrange [""" + range_from_log + """:""" + range_to_log + """]
#             """
#     else:
#         if range_from is None:
#             range_from = '0'
#         if range_to is None:
#             range_to = '1<*'
#         return """
#             set yrange [""" + range_from + """:""" + range_to + """]
#             """


from plumbum.cmd import dstat, bash
from aqmt import processes
from aqmt.plot import collectionutil, treeutil
from aqmt.plot.common import add_plot, add_scale
import os
            set label "Time:" at graph -0.01, graph """ + str(label_y_pos) + """ font 'Times-Roman,11pt' tc rgb 'black' right

            # skip 7 first lines
            set datafile separator ","
            dstat = "\\"< awk '(NR>7){print;}' '""" + testfolder + """/dstat.log'\\""

            plot \\
                @dstat using ($0-2):8 with lines lw 1.5 title 'interrupts', \\
                @dstat using ($0-2):9 with lines lw 1.5 title 'context switches'

            set format y "%h"
            unset datafile
            """
        return {
            'gpi': gpi,
            'skip_sample_line': True,
        }
    return plot


def plot_comparison_int_csw(y_logarithmic=False, keys=True):
    """
    Plot graph of interrupts and context switches
    """

    def plot(tree, plotdef, leaf_hook):
        gap = collectionutil.get_gap(tree)

        gpi = """
            set ylabel "System stats\\n{/Times:Italic=10 Average values}"

# Path: aqmt/processes.py
# def kill_known_pids():
# def add_known_pid(pid):
# def kill_pid(pid):
# def is_running(pid):
# def waitpid(pid):
# 
# Path: aqmt/plot/collectionutil.py
# def get_tree_details(tree):
#     def traverse(branch, depthnow=0):
# def get_gap(tree):
# def get_testcases(leaf):
# def get_all_testcases_folders(tree):
#     def parse_leaf(leaf, first_set, x):
# def make_xtics(tree, xoffset, x_axis):
#     def frange(start, stop, step):
# def get_testmeta_min_max_count(leaf, x_axis):
# def get_x_coordinate(leaf, value, x_axis):
# def merge_testcase_data_set_x(testcases, x_axis):
# def get_leaf_tests_stats(leaf, statsname):
# def merge_testcase_data(leaf, statsname, x_axis):
# def merge_testcase_data_group(leaf, statsname, x_axis):
# def get_xlabel(tree):
#     def fn(leaf, first_set, x):
# def pt_generator():
#     def get_val(tag):
# 
# Path: aqmt/plot/treeutil.py
# def get_depth_sizes(tree):
#     def check_node(item, x, depth):
# def walk_leaf(tree, fn):
#     def walk(branch):
# def walk_tree_reverse(tree, fn):
#     def walk(branch, depth=0):
# def walk_tree(tree, fn, include_leaf_collection=False):
#     def walk(collection, depth=0):
# def swap_levels(tree, level=0):
#         def walk(branch, depth):
#     def check_level(node, x, depth):
#     def build_swap(node, x, depth):
# def build_swap_list(level_order):
# def reorder_levels(tree, level_order=None):
# def skip_levels(tree, number_of_levels):
# 
# Path: aqmt/plot/common.py
# def add_plot(gpi):
#     """
#     Remove trailing comma from plot command because gnuplot complains about it
#     (We use the trailing comma to easier build plot commands)
#     """
#     return re.sub(r',(\s*\\?\s*\\?\s*)$', '\g<1>', gpi)
# 
# def add_scale(y_logarithmic, range_from=None, range_from_log=None,
#         range_to=None, range_to_log=None):
#     if y_logarithmic:
#         if range_from_log is None:
#             range_from_log = '1'
#         if range_to_log is None:
#             range_to_log = '*'
#         return """
#             set logscale y
#             set yrange [""" + range_from_log + """:""" + range_to_log + """]
#             """
#     else:
#         if range_from is None:
#             range_from = '0'
#         if range_to is None:
#             range_to = '1<*'
#         return """
#             set yrange [""" + range_from + """:""" + range_to + """]
#             """


# Path: aqmt/plugins/dstat.py
from plumbum.cmd import dstat, bash
from aqmt import processes
from aqmt.plot import collectionutil, treeutil
from aqmt.plot.common import add_plot, add_scale
import os

            set label "Time:" at graph -0.01, graph """ + str(label_y_pos) + """ font 'Times-Roman,11pt' tc rgb 'black' right

            # skip 7 first lines
            set datafile separator ","
            dstat = "\\"< awk '(NR>7){print;}' '""" + testfolder + """/dstat.log'\\""

            plot \\
                @dstat using ($0-2):8 with lines lw 1.5 title 'interrupts', \\
                @dstat using ($0-2):9 with lines lw 1.5 title 'context switches'

            set format y "%h"
            unset datafile
            """
        return {
            'gpi': gpi,
            'skip_sample_line': True,
        }
    return plot


def plot_comparison_int_csw(y_logarithmic=False, keys=True):
    """
    Plot graph of interrupts and context switches
    """

    def plot(tree, plotdef, leaf_hook):
        gap = collectionutil.get_gap(tree)

        gpi = """
            set ylabel "System stats\\n{/Times:Italic=10 Average values}"

            """ + add_scale(y_logarithmic)