Example #1
0
def get_timings(metagroupname, groupname, times_calculated_over_n_frames):
    """ Get a dictionary of the mean/std and FPS of the timing group.

    :param str metagroupname: The module path for this timing group
    :param str groupname: name of the timing group function name
    :param int times_calculated_over_n_frames: The _TIME["mean"] corresponds to this integer worth
    of frames
    :return: mean/std and FPS of the timing group as a dictionary
    :rtype: dict
    """
    # mean is the time per frame in this code
    print(metagroupname)
    timing_group = timing.get_timing_group(metagroupname)
    time_per_frame = timing_group.summary[groupname][
        "mean"] / times_calculated_over_n_frames
    stddev = f"{timing_group.summary[groupname]['stddev']:.4f}"
    fps = f"{1 / time_per_frame}"
    print(
        f"{groupname}: time_for_all_frames: = {timing_group.summary[groupname]['mean']} +/- "
        f"{stddev}"
        f" or FPS = {fps}")

    return {
        "groupname": groupname,
        "time_per_frame": f"{time_per_frame:.4f}",
        "time_for_all_frames": timing_group.summary[groupname]["mean"],
        "stddev_for_all_frames": stddev,
        "fps": fps
    }
Example #2
0
import timing
import typed_ast.ast3

from transpyle.general import CodeReader
from transpyle.python import PythonAstGeneralizer
from transpyle.python.parser import \
    NativePythonParser, TypedPythonParser, TypedPythonParserWithComments
from transpyle.python.unparser import \
    NativePythonUnparser, TypedPythonUnparser, TypedPythonUnparserWithComments

from .common import EXAMPLES_PY3, basic_check_python_ast, execute_on_language_examples

_LOG = logging.getLogger(__name__)

_TIME = timing.get_timing_group(__name__)

PARSER_CLASSES = (NativePythonParser, TypedPythonParser,
                  TypedPythonParserWithComments)

UNPARSER_CLASSES = (NativePythonUnparser, TypedPythonUnparser,
                    TypedPythonUnparserWithComments)


class ParserTests(unittest.TestCase):
    def test_construct_parser(self):
        for parser_class in PARSER_CLASSES:
            with self.subTest(cls=parser_class):
                parser = parser_class()
                self.assertIsNotNone(parser)
Example #3
0
import signal
import copy
import i3ipc
import pygame
import ctypes
import configparser

global_updates_running = True
global_knowledge = {'active': -1}

i3 = i3ipc.Connection()

screenshot_lib = '/usr/share/i3expo/prtscn.so'
grab = ctypes.CDLL(screenshot_lib)

timer = timing.get_timing_group(__name__)

# PARSE ARGUMENTS
t_args = timer.start("args")
parser = argparse.ArgumentParser(
    description="Display an overview of all open workspaces")
parser.add_argument("-v",
                    "--verbose",
                    help="Print more program data",
                    action='store_true')
parser.add_argument("-i",
                    "--interval",
                    help="Update interval in seconds (default: 1s)")
parser.add_argument("-d",
                    "--dedicated",
                    help="Launch on a dedicated workspace",