Creates an instance of the benchmark plugin with the given name
185490
def build_benchmark_plugin(name: str) -> LaserPlugin:
        
        from mythril.laser.ethereum.plugins.implementations.benchmark import (
            BenchmarkPlugin,
        )

        return BenchmarkPlugin(name)
690646
def create(self, name, plugin_name, hadoop_version, description=None,
               cluster_configs=None, node_groups=None, anti_affinity=None,
               net_id=None, default_image_id=None, use_autoconfig=None,
               shares=None, is_public=None, is_protected=None,
               domain_name=None):
        """"""

        data = {
            'name': name,
            'plugin_name': plugin_name,
            'hadoop_version': hadoop_version,
        }

        return self._do_create(data, description, cluster_configs,
                               node_groups, anti_affinity, net_id,
                               default_image_id, use_autoconfig, shares,
                               is_public, is_protected, domain_name)
474875
def create_instance(self, name, moduleName, settings):
        
        if name in self.insts:
            raise ValueError("There's already an instance named %s" %
                             name)
        if moduleName not in self.modules:
            raise ValueError("There's no module %s" % moduleName)
        md = self.modules[moduleName]
        deps = dict()
        for k, v in six.iteritems(md.deps):
            if k not in settings:
                settings[k] = self._get_or_create_a(v.type)
            if settings[k] is None:
                if not v.allow_null:
                    raise ValueError("`null' not allowed for %s" % k)
            elif settings[k] not in self.insts:
                raise ValueError("No such instance %s" % settings[k])
            else:
                settings[k] = self.insts[settings[k]].object
                deps[k] = settings[k]
        for k, v in six.iteritems(md.vsettings):
            if k not in settings:
                settings[k] = v.default
                if v.default is None:
                    self.l.warn('%s:%s not set' % (name, k))
        self.l.info('create_instance %-15s %s' % (name, md.implementedBy))
        cl = get_by_path(md.implementedBy)
        il = logging.getLogger(name)
        obj = cl(settings, il)
        self.register_instance(name, moduleName, obj, settings, deps)
        return obj
728485
def benchmark_method(f):
    ""
    @wraps(f)
    def inner(name, *args, **kwargs):
        return Benchmark(name, f, args, kwargs)
    return inner
1022053
def create (self, name, *args):
        """"""
        tab  = None
        defn = self.get(name, None)
        if defn:
            tab = FSWTab(defn, *args)
        return tab
95037
def validate(self, benchmarks):
        
        class_code = self.setup_src
        instance_creation = '\ninstance = {}'.format(self.stmt)
        for i, benchmark in enumerate(benchmarks):
            if not benchmark.result_validation:
                break

            validation_code = class_code + instance_creation + '\nvalidation_result = ' + benchmark.stmt
            validation_scope = {}
            exec(validation_code, validation_scope)
            # Store the result in the first function in the group.
            if i == 0:
                compare_against_function = benchmarks[0].callable.__name__
                compare_against_result = validation_scope['validation_result']
                logging.info('PyPerform: Validating group "{b.group}" against method '
                             '"{b.classname}.{b.callable.__name__}"'.format(b=benchmarks[0]))
            else:
                if compare_against_result == validation_scope['validation_result']:
                    logging.info('PyPerform: Validating {b.classname}.{b.callable.__name__}......PASSED!'
                                 .format(b=benchmark))
                else:
                    error = 'Results of functions {0} and {1} are not equivalent.\n{0}:\t {2}\n{1}:\t{3}'
                    raise ValidationError(error.format(compare_against_function, benchmark.callable.__name__,
                                              compare_against_result, validation_scope['validation_result']))
409740
def plugin(name):
        
        cls = XChartRenderer._plugins.get(name)
        if cls:
            renderer = cls()
            renderer.setName(name)
            return renderer
        return None
364052
private Map<Class<?>, Object> executeBeforeBenchClass(
			final Map<Class<?>, Object> instantiatedObj,
			final BenchmarkResult res) {

		final Map<Class<?>, Object> returnVal = new Hashtable<Class<?>, Object>();

		// invoking before bench class
		for (final Class<?> clazz : instantiatedObj.keySet()) {

			final Object objectToUse = instantiatedObj.get(clazz);
			// ..the search for the beforeClassMeth begins...
			Method beforeClassMeth = null;
			boolean continueVal = true;
			try {
				beforeClassMeth = BenchmarkMethod
						.findAndCheckAnyMethodByAnnotation(clazz,
								BeforeBenchClass.class);
				// ... and if this search is throwing an exception, the
				// exception will be added and a flag is set to break up
			} catch (final PerfidixMethodCheckException e) {
				res.addException(e);
				continueVal = false;
			}
			// if everything worked well...
			if (continueVal) {
				if (beforeClassMeth == null) {
					// ...either the objects is directly mapped to the class
					// for executing the benches
					returnVal.put(clazz, objectToUse);
				} else {
					// ... or the beforeMethod will be executed and a
					// possible exception stored to the result...
					final PerfidixMethodCheckException beforeByCheck = BenchmarkExecutor
							.checkMethod(objectToUse, BeforeBenchClass.class,
									beforeClassMeth);
					if (beforeByCheck == null) {
						final PerfidixMethodInvocationException beforeByInvok = BenchmarkExecutor
								.invokeMethod(objectToUse,
										BeforeBenchClass.class, beforeClassMeth);
						if (beforeByInvok == null) {
							returnVal.put(clazz, objectToUse);
						} else {
							res.addException(beforeByInvok);
						}
					} else {
						res.addException(beforeByCheck);
					}
				}
			}
		}
		return returnVal;
	}
1015816
function createNamedClass (name, klass, baseKlass, superFunc) {
    if (!superFunc) {
        superFunc = function () {
            baseKlass.call(this);
        };
    }
    
    return new Function(
        'klass', 'superFunc',
        'return function ' + name + ' () {' +
            'superFunc.apply(this, arguments);' +
            'klass.apply(this, arguments);' +
        '};'
        )(klass, superFunc);
}
361223
def create_instance(self, name, template, args=None, labels=None):
        
        req = rest_pb2.CreateInstanceRequest()
        req.name = name
        req.template = template
        if args:
            for k in args:
                req.templateArgs[k] = args[k]
        if labels:
            for k in labels:
                req.labels[k] = labels[k]
        url = '/instances'
        self.post_proto(url, data=req.SerializeToString())
81734
def get_create_func(base_class, nickname):
    
    if base_class not in _REGISTRY:
        _REGISTRY[base_class] = {}
    registry = _REGISTRY[base_class]

    def create(*args, **kwargs):
        """Create instance from config"""
        if len(args):
            name = args[0]
            args = args[1:]
        else:
            name = kwargs.pop(nickname)

        if isinstance(name, base_class):
            assert len(args) == 0 and len(kwargs) == 0, \
                "%s is already an instance. Additional arguments are invalid"%(nickname)
            return name

        if isinstance(name, dict):
            return create(**name)

        assert isinstance(name, string_types), "%s must be of string type"%nickname

        if name.startswith('['):
            assert not args and not kwargs
            name, kwargs = json.loads(name)
            return create(name, **kwargs)
        elif name.startswith('{'):
            assert not args and not kwargs
            kwargs = json.loads(name)
            return create(**kwargs)

        name = name.lower()
        assert name in registry, \
            "%s is not registered. Please register with %s.register first"%(
                str(name), nickname)
        return registry[name](*args, **kwargs)

    create.__doc__ = """Create a %s instance from config.

Parameters
----------
%s : str or %s instance
    class name of desired instance. If is a instance,
    it will be returned directly.
**kwargs : dict
    arguments to be passed to constructor"""%(nickname, nickname, base_class.__name__)

    return create
973220
def get_instance(self, node, *args, **kwargs):
        
        # string is a ref to an existing plugin instance
        if isinstance(node, basestring):
            if node in self._instance:
                return self._instance[node]
            # if not an instance, try for init with empty config
            return self.new_plugin({'type': node}, *args, **kwargs)

        if isinstance(node, collections.Mapping):
            if "type" in node:
                # node was a plugin config passed directly
                name = node.get("name", node.get("type"))
            elif len(node) == 1:
                # node was a container with a single plugin config keyed
                # to it
                typ, config = list(node.items())[0]
                name = config.get("name", config.get("type", typ))

            # retrieve existing instance if it exists
            if name in self._instance:
                return self._instance[name]

            # otherwise spawn new plugin
            return self.new_plugin(node, *args, **kwargs)

        raise ValueError("unable to parse plugin for output %s" % str(node))
809440
protected <T> T createInstance(String typeName) throws PluginRepositoryException {
        Class<T> type = getType(typeName.trim());
        try {
            return type.newInstance();
        } catch (InstantiationException e) {
            throw new PluginRepositoryException("Cannot create instance of class " + type.getName(), e);
        } catch (IllegalAccessException e) {
            throw new PluginRepositoryException("Cannot access class " + typeName, e);
        } catch (LinkageError e) {
            throw new PluginRepositoryException("Cannot load plugin class " + typeName, e);
        }
    }
854702
def plugin(cls, name):
        
        cls.loadPlugins()
        plugs = getattr(cls, '_%s__plugins' % cls.__name__, {})
        return plugs.get(nstr(name))
1096807
function benchmark(name, fn) {

        // Prepare innerloop function
        var innerLoop = eval(
            "(function(f) {" +
            "   return function innerLoop4" + fn.name + "(n) {" +
            "       for (var i = 0; i < n; i++) f()" +
            "   };" +
            "})")(fn);

        // Pre test
        var timeExcess = testTime * 1.1;
        var init = Date.now();
        innerLoop(preTestIterations, fn);
        var elapsed = Date.now() - init + 1;
        var iterations = 0 | Math.min(maxIterations, timeExcess / elapsed * 1000);

        // Test
        var checks = 0;
        var totalIterations = 0;
        init = Date.now();
        do {
            innerLoop(iterations);
            totalIterations += iterations;
            checks++;
            elapsed = Date.now() - init;
            if (elapsed >= testTime) break;
            iterations = 0 | Math.min(maxIterations, (timeExcess - elapsed) / (elapsed + 1) * totalIterations);
        } while (elapsed < testTime);

        // Stats
        var secs = elapsed / 1000;
        var perSecondIterations = 0 | totalIterations / secs;
        if (verbose) {
            console.log('Function "%s" running for %d seconds: %s checks, %s total iterations, %s iterations per second',
                name,
                Math.round(secs * 100) / 100,
                checks,
                totalIterations.toLocaleString(),
                perSecondIterations.toLocaleString()
            );
        }

        // Global stats
        benchmark.results.push({
            name: name,
            elapsed: elapsed,
            checks: checks,
            totalIterations: totalIterations,
            perSecondIterations: perSecondIterations,
            isOptimized: checkOptimization ? isOptimized(fn) : null
        });
        benchmark.results.sort(function (a, b) {
            return b.perSecondIterations - a.perSecondIterations;}
        );
        var max = benchmark.results[0].perSecondIterations;
        benchmark.results.forEach(function (a) {
            return a.diff = Math.round((max - a.perSecondIterations) / max * 10000) / 100 + "%";
        });

    }
496400
def get_plugin(self, name):
        
        for plugin in self.plugins:
            if plugin.name == name:
                return plugin

        raise PluginDoesNotExistError("Plugin '{}' not found".format(name))
263481
function runBenchmark(benchmark, environments) {
  let benchmarkName;
  const benches = environments.map(environment => {
    const module = require(path.join(environment.distPath, benchmark))
    benchmarkName = module.name;
    return new Benchmark(environment.revision, module.measure);
  });

  console.log('⏱️   ' + benchmarkName);
  for (let i = 0; i < benches.length; ++i) {
    benches[i].run({ async: false });
    process.stdout.write('  ' + cyan(i + 1) + ' tests completed.\u000D');
  }
  console.log('\n');

  beautifyBenchmark(benches);
  console.log('');
}