Profile a single executable statement in the given namespaces.
343783
def runctx(self, cmd, globals, locals):
        
        self.enable_by_count()
        try:
            exec(cmd, globals, locals)
        finally:
            self.disable_by_count()
        return self
1271286
function(namespace, target) {
      
      target = target || {};
      
      var names = namespace.split('.'),
          context = target;
      
      for (var i = 0; i < names.length; i++) {
        var name = names[i];
        context = (name in context) ? context[name] : (context[name] = {});
      }
      
      return target;
    }
60330
def _run_cmd(cmd, ctx, glob, loc):  # pragma: no cover
    """"""
    if PDB:
        _enable_pdb()
    if IPYTHON:
        from IPython import start_ipython
        args_ipy = ['-i', '--gui=qt']
        ns = glob.copy()
        ns.update(loc)
        return start_ipython(args_ipy, user_ns=ns)
    # Profiling. The builtin `profile` is added in __init__.
    prof = __builtins__.get('profile', None)
    if prof:
        prof = __builtins__['profile']
        return _profile(prof, cmd, glob, loc)
    return exec_(cmd, glob, loc)
648474
def _rt_parse_execs(self, statement, element, mode, lineparser):
        """"""
        #This is the same deal as with _rt_parse_types() below.
        if mode == "insert":
            enew, start, end = self.xparser.parse_signature(statement, element, element)
            if enew is not None:
                enew.start, enew.end = lineparser.absolute_charindex(statement, start, end)
                enew.incomplete = True
                element.executables[enew.name.lower()] = enew
                lineparser.additions.append((enew, element))
645371
function build_ext_define_patterns(namespaces) {
  var mappedNamespaced = _.map(namespaces, function(ns) {
    [ns + ".define", ns + ".ClassManager.create"]
  });
  return _.flatten(mappedNamespaced);
}
789261
def _descend_namespace(caller_globals, name):
    
    names =  name.split('.')
    cur = caller_globals
    for i in names:
        if type(cur) is dict:
            cur = cur[i]
        else:
            cur = getattr(cur, i)
    return cur
1375004
def profile(fun, *args, **kwargs):
    
    timer_name = kwargs.pop("prof_name", None)

    if not timer_name:
        module = inspect.getmodule(fun)
        c = [module.__name__]
        parentclass = labtypes.get_class_that_defined_method(fun)
        if parentclass:
            c.append(parentclass.__name__)
        c.append(fun.__name__)
        timer_name = ".".join(c)

    start(timer_name)
    ret = fun(*args, **kwargs)
    stop(timer_name)
    return ret
535365
def add_namespace_statistics(self, namespace, offset, data_points,
                                 byte_count):
        """"""
        query = 'UPDATE gauged_statistics ' \
            'SET data_points = data_points + %s,' \
            'byte_count = byte_count + %s WHERE namespace = %s ' \
            'AND "offset" = %s; INSERT INTO gauged_statistics ' \
            'SELECT %s, %s, %s, %s WHERE NOT EXISTS (' \
            'SELECT 1 FROM gauged_statistics WHERE namespace = %s' \
            'AND "offset" = %s)'
        self.cursor.execute(query, (data_points, byte_count, namespace,
                                    offset, namespace, offset, data_points,
                                    byte_count, namespace, offset))
547306
def line_is_executable(line: str) -> bool:
    """"""

    if line_is_comment(line):
        return False

    if re.match(RE_TYPE_NAMES, line):
        return False

    for exp in EXECUTABLE_CODE_START:
        if re.match(exp, line) != None:
            return True

    return False
573287
def _format_executable(lines, element, spacer=""):
    
    rlines = []
    rlines.append(element.signature)
    _format_summary(rlines, element)

    rlines.append("")
    rlines.append("PARAMETERS")
    for p in element.ordered_parameters:
        _format_value_element(rlines, p)

    rlines.append("")
    _format_generic(rlines, element, ["summary"])

    #Subroutines can have embedded types and functions which need to be handled.
    if len(element.types) > 0:
        rlines.append("\nEMBEDDED TYPES")
        for key, value in list(element.types.items()):
            _format_type(rlines, value, "  ")

    if len(element.executables) > 0:
        rlines.append("\nEMBEDDED EXECUTABLES")
        for key, value in list(element.executables.items()):
            _format_executable(rlines, value, "  ")

    lines.extend([spacer + l for l in rlines])
374459
def __profile_file(self):
        """"""
        self.line_profiler = pprofile.Profile()
        self.line_profiler.runfile(
            open(self.pyfile.path, "r"), {}, self.pyfile.path
        )
437013
def write_namespaces(self, namespaces):
        """"""
        self.printer.writelines(
            "def _mako_get_namespace(context, name):",
                "try:",
                    "return context.namespaces[(__name__, name)]",
                "except KeyError:",
                    "_mako_generate_namespaces(context)",
                "return context.namespaces[(__name__, name)]",
            None, None
        )
        self.printer.writeline("def _mako_generate_namespaces(context):")


        for node in namespaces.values():
            if 'import' in node.attributes:
                self.compiler.has_ns_imports = True
            self.printer.start_source(node.lineno)
            if len(node.nodes):
                self.printer.writeline("def make_namespace():")
                export = []
                identifiers = self.compiler.identifiers.branch(node)
                self.in_def = True
                class NSDefVisitor(object):
                    def visitDefTag(s, node):
                        s.visitDefOrBase(node)

                    def visitBlockTag(s, node):
                        s.visitDefOrBase(node)

                    def visitDefOrBase(s, node):
                        if node.is_anonymous:
                            raise exceptions.CompileException(
                                "Can't put anonymous blocks inside "
                                "<%namespace>",
                                **node.exception_kwargs
                            )
                        self.write_inline_def(node, identifiers, nested=False)
                        export.append(node.funcname)
                vis = NSDefVisitor()
                for n in node.nodes:
                    n.accept_visitor(vis)
                self.printer.writeline("return [%s]" % (','.join(export)))
                self.printer.writeline(None)
                self.in_def = False
                callable_name = "make_namespace()"
            else:
                callable_name = "None"

            if 'file' in node.parsed_attributes:
                self.printer.writeline(
                                "ns = runtime.TemplateNamespace(%r,"
                                " context._clean_inheritance_tokens(),"
                                " templateuri=%s, callables=%s, "
                                " calling_uri=_template_uri)" %
                                (
                                    node.name,
                                    node.parsed_attributes.get('file', 'None'),
                                    callable_name,
                                )
                            )
            elif 'module' in node.parsed_attributes:
                self.printer.writeline(
                                "ns = runtime.ModuleNamespace(%r,"
                                " context._clean_inheritance_tokens(),"
                                " callables=%s, calling_uri=_template_uri,"
                                " module=%s)" %
                                (
                                    node.name,
                                    callable_name,
                                    node.parsed_attributes.get(
                                                'module', 'None')
                                )
                            )
            else:
                self.printer.writeline(
                                "ns = runtime.Namespace(%r,"
                                " context._clean_inheritance_tokens(),"
                                " callables=%s, calling_uri=_template_uri)" %
                                (
                                    node.name,
                                    callable_name,
                                )
                            )
            if eval(node.attributes.get('inheritable', "False")):
                self.printer.writeline("context['self'].%s = ns" % (node.name))

            self.printer.writeline(
                "context.namespaces[(__name__, %s)] = ns" % repr(node.name))
            self.printer.write_blanks(1)
        if not len(namespaces):
            self.printer.writeline("pass")
        self.printer.writeline(None)
708821
def run_display_profile(self, program_main):
        
        install_json = self.profile.get('install_json')

        output = 'Profile: '
        output += '{}{}{}{} '.format(
            c.Style.BRIGHT, c.Fore.CYAN, self.profile.get('profile_name'), c.Style.RESET_ALL
        )
        output += '[{}{}{}{}'.format(
            c.Style.BRIGHT, c.Fore.MAGENTA, program_main, c.Style.RESET_ALL
        )
        if install_json.get('programVersion') is not None:
            output += '{}:{}'.format(c.Style.BRIGHT, c.Style.RESET_ALL)
            output += '{}{}{}{}'.format(
                c.Style.BRIGHT,
                c.Fore.MAGENTA,
                install_json.get('programVersion'),
                c.Style.RESET_ALL,
            )
        output += ']'
        print(output)
47710
def profile(prof=None, instances=None, opts=None, **kwargs):
    '''
    
    '''
    if prof is None and 'profile' in kwargs:
        prof = kwargs['profile']

    if prof is None:
        return {'Error': 'A profile (or prof) must be defined'}

    if instances is None and 'names' in kwargs:
        instances = kwargs['names']

    if instances is None:
        return {'Error': 'One or more instances (comma-delimited) must be set'}

    client = _get_client()
    if isinstance(opts, dict):
        client.opts.update(opts)
    info = client.profile(prof, instances, **salt.utils.args.clean_kwargs(**kwargs))
    return info
512157
function extractMetaNodes(profile) {
        const topLevelNodes = profile.resultRoot.children;
        for (let i = 0; i < topLevelNodes.length && !(profile.gcNode && profile.programNode && profile.idleNode); i++) {
            const node = topLevelNodes[i];
            if (node.functionName === '(garbage collector)')
                profile.gcNode = node;
            else if (node.functionName === '(program)')
                profile.programNode = node;
            else if (node.functionName === '(idle)')
                profile.idleNode = node;
        }
    }
352482
def invocation():
    """"""
    cmdargs = [sys.executable] + sys.argv[:]
    invocation = " ".join(shlex.quote(s) for s in cmdargs)
    return invocation
264608
def profile_execution(self, status):
        """"""
        self.selected_profile.data['execution_success'] = status
        if status:
            self.report['results']['executions']['pass'] += 1
        else:
            self.report['results']['executions']['fail'] += 1
            if self.selected_profile.name not in self.report['results']['failed_profiles']:
                self.report['results']['failed_profiles'].append(self.selected_profile.name)