Sets CPU core count to the given value

    config_spec
        vm.ConfigSpec object

    cpu_props
        CPU properties dict
971649
def _apply_cpu_config(config_spec, cpu_props):
    '''
    
    '''
    log.trace('Configuring virtual machine CPU '
              'settings cpu_props=%s', cpu_props)
    if 'count' in cpu_props:
        config_spec.numCPUs = int(cpu_props['count'])
    if 'cores_per_socket' in cpu_props:
        config_spec.numCoresPerSocket = int(cpu_props['cores_per_socket'])
    if 'nested' in cpu_props and cpu_props['nested']:
        config_spec.nestedHVEnabled = cpu_props['nested']  # True
    if 'hotadd' in cpu_props and cpu_props['hotadd']:
        config_spec.cpuHotAddEnabled = cpu_props['hotadd']  # True
    if 'hotremove' in cpu_props and cpu_props['hotremove']:
        config_spec.cpuHotRemoveEnabled = cpu_props['hotremove']
1101164
def set(cls, var_name: str, value: Any) -> 'Configuration':
        
        with cls._lock:
            if var_name not in cls().cache:
                cls().cache[var_name] = value
            else:
                raise ConfigurationError(
                    f'Value for {var_name} already set')
        return cls()
852674
function cpuTemperature() {
  if (_windows) {
    return(NOT_SUPPORTED);
  }
  if (_linux) {
    return(NOT_SUPPORTED);
  }

  if (_darwin) {
    let result = {
      main: -1.0,
      cores: [],
      max: -1.0
    };
    let smc = require('../build/Release/smc');

    let cores = ['TC0P', 'TC1C', 'TC2C', 'TC3C', 'TC4C', 'TC5C', 'TC6C', 'TC7C', 'TC8C'];
    let sum = 0;
    let id = 0;
    cores.forEach(function(key) {
      let value = smc.get(key);
      if (id === 0) {
        if (value > 0) {
          result.main = value;
          result.max = value;
        }
        id = 1;
      } else {
        if (value > 0) {
          result.cores.push(value);
          sum = sum + value;
          if (value > result.max) result.max = value;
        }
      }
    });
    if (result.cores.length) {
      result.main = sum / result.cores.length;
    }

    return(result);
  }
}
864244
def set_value(self, name, value, PY2_frontend):
        """"""
        import cloudpickle
        ns = self._get_reference_namespace(name)

        # We send serialized values in a list of one element
        # from Spyder to the kernel, to be able to send them
        # at all in Python 2
        svalue = value[0]

        # We need to convert svalue to bytes if the frontend
        # runs in Python 2 and the kernel runs in Python 3
        if PY2_frontend and not PY2:
            svalue = bytes(svalue, 'latin-1')

        # Deserialize and set value in namespace
        dvalue = cloudpickle.loads(svalue)
        ns[name] = dvalue
        self.log.debug(ns)
333865
def set(self, key, value):
        
        # the configuration changes, so we invalidate the cached config
        self._full_config = None
        self._override[key] = value
621315
function set(key, value) {
  var k = this.getKey(key);
  var name = this.getName(key);
  if(this.conf.native && typeof(value) == 'string') {
    try {
      value = native.to(
        value, this.conf.native.delimiter, this.conf.native.json);
    }catch(e){}
  }
  this[name] = process.env[k] = value;
}
299665
def set_parameter_values(self, values):
        
        req = rest_pb2.BulkSetParameterValueRequest()
        for key in values:
            item = req.request.add()
            item.id.MergeFrom(_build_named_object_id(key))
            item.value.MergeFrom(_build_value_proto(values[key]))
        url = '/processors/{}/{}/parameters/mset'.format(
            self._instance, self._processor)
        self._client.post_proto(url, data=req.SerializeToString())
828019
def cpu():
    '''
    
    '''

    # Test data
    max_primes = [500, 1000, 2500, 5000]

    # Initializing the test variables
    test_command = 'sysbench --test=cpu --cpu-max-prime={0} run'
    result = None
    ret_val = {}

    # Test beings!
    for primes in max_primes:
        key = 'Prime numbers limit: {0}'.format(primes)
        run_command = test_command.format(primes)
        result = __salt__['cmd.run'](run_command)
        ret_val[key] = _parser(result)

    return ret_val
1161342
def GetNumCoresOnHosts(hosts, private_key):
  
  results = runner.Runner(host_list=hosts, private_key=private_key,
                          module_name='setup').run()
  num_cores_list = []
  for _, props in results['contacted'].iteritems():
    cores = props['ansible_facts']['ansible_processor_cores']
    val = 0
    try:
      val = int(cores)
    except ValueError:
      pass
    num_cores_list.append(val)
  return num_cores_list
224266
def cpuinfo():
    """"""
    f = open("/proc/cpuinfo")
    hwinfo = {}
    for line in f.readlines():
        cpul = line.split(":")
        name = cpul[0].strip()
        if (len(cpul) > 1):
            val = cpul[1].strip()
        if (name == "model name"):
            hwinfo["CPU"] = val
        elif (name == "cpu MHz"):
            hwinfo["MHz"] = int(round(float(val)))
    f.close()
    return hwinfo
541676
function set(appName, limits, callback) {
    if (!isObject(limits)) {
      return callback(new Error('To set a variable pass an object'));
    }

    var keyValues = {};

    if (limits.hasOwnProperty('memory')) {
      keyValues.memory = limits.memory;
    }

    if (limits.hasOwnProperty('cpu')) {
      keyValues.cpu = limits.cpu;
    }

    if (Object.keys(keyValues).length === 0) {
      return callback(new Error('Only cpu and memory limits are valid'));
    }

    commons.post(format('/%s/apps/%s/config/', deis.version, appName), keyValues,
        function onSetResponse(err, result) {
          callback(err, result ? extractLimits(result) : null);
        });
  }
132401
def _apply_memory_config(config_spec, memory):
    '''
    
    '''
    log.trace('Configuring virtual machine memory '
              'settings memory=%s', memory)
    if 'size' in memory and 'unit' in memory:
        try:
            if memory['unit'].lower() == 'kb':
                memory_mb = memory['size'] / 1024
            elif memory['unit'].lower() == 'mb':
                memory_mb = memory['size']
            elif memory['unit'].lower() == 'gb':
                memory_mb = int(float(memory['size']) * 1024)
        except (TypeError, ValueError):
            memory_mb = int(memory['size'])
        config_spec.memoryMB = memory_mb
    if 'reservation_max' in memory:
        config_spec.memoryReservationLockedToMax = memory['reservation_max']
    if 'hotadd' in memory:
        config_spec.memoryHotAddEnabled = memory['hotadd']
1326462
def set_cpu_affinity(n, process_ids, actual=not Conf.TESTING):
    
    # check if we have the psutil module
    if not psutil:
        logger.warning('Skipping cpu affinity because psutil was not found.')
        return
    # check if the platform supports cpu_affinity
    if actual and not hasattr(psutil.Process(process_ids[0]), 'cpu_affinity'):
        logger.warning('Faking cpu affinity because it is not supported on this platform')
        actual = False
    # get the available processors
    cpu_list = list(range(psutil.cpu_count()))
    # affinities of 0 or gte cpu_count, equals to no affinity
    if not n or n >= len(cpu_list):
        return
    # spread the workers over the available processors.
    index = 0
    for pid in process_ids:
        affinity = []
        for k in range(n):
            if index == len(cpu_list):
                index = 0
            affinity.append(cpu_list[index])
            index += 1
        if psutil.pid_exists(pid):
            p = psutil.Process(pid)
            if actual:
                p.cpu_affinity(affinity)
            logger.info(_('{} will use cpu {}').format(pid, affinity))
1371763
def variable_on_cpu(name, shape, initializer):
    
    """
    # Use the /cpu:0 device for scoped operations
    with tf.device(Config.cpu_device):
        # Create or get apropos variable
        var = tf.get_variable(name=name, shape=shape, initializer=initializer)
    return var
169518
function() {
        if (process.platform !== 'win32') {
            return;
        }

        this._cpuConsole = child_process.spawn('typeperf', ['\\Processor(_Total)\\% Processor Time']);
        this._cpuConsole.stdout.on('data', _.bind(function(stdout) {

            stdout = stdout.toString();
            if (stdout && stdout.indexOf(',') === 0) {
                var cpu = parseFloat(stdout.substr(2, stdout.length - 3));
                this._cpuFrame(cpu);
            }
        }, this));
    }
1227644
def set(self, key, value):
        """"""
        # Try to set self._jconf first if JVM is created, set self._conf if JVM is not created yet.
        if self._jconf is not None:
            self._jconf.set(key, unicode(value))
        else:
            self._conf[key] = unicode(value)
        return self
268308
def get_passenger_cpu_usage(self, dict_stats):
        
        try:
            proc1 = subprocess.Popen(
                ["top", "-b", "-n", "2"],
                stdout=subprocess.PIPE)
            (std_out, std_err) = proc1.communicate()
        except OSError:
            return (-1)

        re_lspaces = re.compile("^\s*")
        re_digit = re.compile("^\d")
        overall_cpu = 0
        for raw_line in std_out.splitlines():
            line = re_lspaces.sub("", raw_line)
            if not re_digit.match(line):
                continue

            line_splitted = line.split()
            if line_splitted[0] in dict_stats["apache_procs"]:
                overall_cpu += float(line_splitted[8])
            elif line_splitted[0] in dict_stats["nginx_procs"]:
                overall_cpu += float(line_splitted[8])
            elif line_splitted[0] in dict_stats["passenger_procs"]:
                overall_cpu += float(line_splitted[8])

        return overall_cpu