當前位置: 首頁>>代碼示例>>Python>>正文


Python cpuinfo.get_cpu_info方法代碼示例

本文整理匯總了Python中cpuinfo.get_cpu_info方法的典型用法代碼示例。如果您正苦於以下問題:Python cpuinfo.get_cpu_info方法的具體用法?Python cpuinfo.get_cpu_info怎麽用?Python cpuinfo.get_cpu_info使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在cpuinfo的用法示例。


在下文中一共展示了cpuinfo.get_cpu_info方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def main():
    os.system("clear")
    print("\t" + "#" * 80 + "#")
    print("\t" + "#\033[91m\t[*] This is a simple script to show your system information\033[0m\t\t" + "#")
    print("\t" + "#" * 80 + "#")
    print("")

    print("\033[91m\tTime: \033[0m" + time.ctime())
    print("\033[91m\tCurrent directory: \033[0m" + os.getcwd())
    print("\033[91m\tPython Version: \033[0m" + cpuinfo.get_cpu_info()["python_version"])
    print("\033[91m\tOperation System: \033[0m" + platform.system())
    print("\033[91m\tNode: \033[0m" + platform.node())
    print("\033[91m\tOS Version: \033[0m" + platform.uname()[3])
    print("\033[91m\tSystem Type: \033[0m" + platform.architecture()[0])
    print("\033[91m\tCores: \033[0m" + str(cpuinfo.get_cpu_info()["count"]))
    print("\033[91m\tCPU: \033[0m" + cpuinfo.get_cpu_info()["brand"]) 
開發者ID:Naategh,項目名稱:PyCk,代碼行數:18,代碼來源:sysInfo.py

示例2: cpu_info

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def cpu_info(self) -> CpuInfoResponse:
        """
        Get CPU info.
        :return: :class:`platypush.message.response.system.CpuInfoResponse`
        """
        from cpuinfo import get_cpu_info
        info = get_cpu_info()

        return CpuInfoResponse(
            arch=info.get('raw_arch_string'),
            bits=info.get('bits'),
            count=info.get('count'),
            vendor_id=info.get('vendor_id'),
            brand=info.get('brand'),
            hz_advertised=info.get('hz_advertised_raw')[0],
            hz_actual=info.get('hz_actual_raw')[0],
            stepping=info.get('stepping'),
            model=info.get('model'),
            family=info.get('family'),
            flags=info.get('flags'),
            l1_instruction_cache_size=info.get('l1_instruction_cache_size'),
            l1_data_cache_size=info.get('l1_data_cache_size'),
            l2_cache_size=info.get('l2_cache_size'),
            l3_cache_size=info.get('l3_cache_size'),
        ) 
開發者ID:BlackLight,項目名稱:platypush,代碼行數:27,代碼來源:__init__.py

示例3: main

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def main():
    file = open(
        "bench_result" + str(datetime.datetime.now().strftime("%Y-%m-%d-%H-%M")), "w"
    )
    gen = CubeGen(number_dimensions=3, rows_length=1000, columns_length=5)
    gen.generate_csv(gen.generate_cube(3, 1000))
    mbench = MicBench()
    file.write("Benchmarks are made with cpu :\n")
    file.write(cpuinfo.get_cpu_info()["brand"] + "\n\n")

    mdx_engine = MdxEngine()
    mdx_engine.load_cube(CUBE_NAME)
    wsgi_application = get_wsgi_application(mdx_engine)
    server = WSGIServer(application=wsgi_application, host=HOST, port=PORT)
    server.start()
    provider = xmla.XMLAProvider()
    conn = provider.connect(location=server.url)
    olapy_query_execution_bench(file, mbench, conn, mdx_engine)
    olapy_vs_mondrian(file, mbench, conn)
    olapy_vs_iccube(file, mbench, conn)
    olapy_profile(file)
    gen.remove_temp_cube()
    file.close()
    server.stop() 
開發者ID:abilian,項目名稱:olapy,代碼行數:26,代碼來源:csv_olapy_bench_vs_other_olap_servers.py

示例4: pytest_benchmark_generate_machine_info

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def pytest_benchmark_generate_machine_info():
    python_implementation = platform.python_implementation()
    python_implementation_version = platform.python_version()
    if python_implementation == 'PyPy':
        python_implementation_version = '%d.%d.%d' % sys.pypy_version_info[:3]
        if sys.pypy_version_info.releaselevel != 'final':
            python_implementation_version += '-%s%d' % sys.pypy_version_info[3:]
    return {
        "node": platform.node(),
        "processor": platform.processor(),
        "machine": platform.machine(),
        "python_compiler": platform.python_compiler(),
        "python_implementation": python_implementation,
        "python_implementation_version": python_implementation_version,
        "python_version": platform.python_version(),
        "python_build": platform.python_build(),
        "release": platform.release(),
        "system": platform.system(),
        "cpu": get_cpu_info(),
    } 
開發者ID:ionelmc,項目名稱:pytest-benchmark,代碼行數:22,代碼來源:plugin.py

示例5: get_cpu_model

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def get_cpu_model():
    return cpuinfo.get_cpu_info()['brand'] 
開發者ID:BennyThink,項目名稱:ServerSan,代碼行數:4,代碼來源:ss-agent.py

示例6: get_cpu_freq

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def get_cpu_freq():
    # psutil won't return current cpu freq in visualization.
    # return psutil.cpu_freq()[0]
    return round(float(cpuinfo.get_cpu_info()['hz_actual'].split(' ')[0]), 2) 
開發者ID:BennyThink,項目名稱:ServerSan,代碼行數:6,代碼來源:ss-agent.py

示例7: collect_system_information

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def collect_system_information(self):
        values = {}
        mem = psutil.virtual_memory()
        values['memory_total'] = mem.total

        import cpuinfo
        cpu = cpuinfo.get_cpu_info()
        values['resources_limit'] = self.resources_limit
        values['cpu_name'] = cpu['brand']
        values['cpu'] = [cpu['hz_advertised_raw'][0], cpu['count']]
        values['nets'] = {}
        values['disks'] = {}
        values['gpus'] = {}
        values['boot_time'] = psutil.boot_time()

        try:
            for gpu_id, gpu in enumerate(aetros.cuda_gpu.get_ordered_devices()):
                gpu['available'] = gpu_id in self.enabled_gpus

                values['gpus'][gpu_id] = gpu
        except aetros.cuda_gpu.CudaNotImplementedException: pass

        for disk in psutil.disk_partitions():
            try:
                name = self.get_disk_name(disk[1])
                values['disks'][name] = psutil.disk_usage(disk[1]).total
            except Exception:
                # suppress Operation not permitted
                pass

        try:
            for id, net in psutil.net_if_stats().items():
                if 0 != id.find('lo') and net.isup:
                    self.nets.append(id)
                    values['nets'][id] = net.speed or 1000
        except Exception:
            # suppress Operation not permitted
            pass

        return values 
開發者ID:aetros,項目名稱:aetros-cli,代碼行數:42,代碼來源:ServerCommand.py

示例8: collect_system_information

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def collect_system_information(self):
        import psutil

        mem = psutil.virtual_memory()

        with self.git.batch_commit('JOB_SYSTEM_INFORMATION'):
            self.set_system_info('memory_total', mem.total)

            import cpuinfo
            cpu = cpuinfo.get_cpu_info()
            self.set_system_info('cpu_name', cpu['brand'])
            self.set_system_info('cpu', [cpu['hz_actual_raw'][0], cpu['count']]) 
開發者ID:aetros,項目名稱:aetros-cli,代碼行數:14,代碼來源:backend.py

示例9: _get_cpu_by_pycpuinfo

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def _get_cpu_by_pycpuinfo():
    return cpuinfo.get_cpu_info().get("brand", "Unknown") 
開發者ID:IDSIA,項目名稱:sacred,代碼行數:4,代碼來源:host_info.py

示例10: get_global

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def get_global(key: Optional[str] = None) -> Union[str, Dict[str, Any]]:
    import cpuinfo
    import psutil

    # TODO (wardlt): Implement a means of getting CPU information from compute nodes on clusters for MPI tasks
    #  The QC code runs on a different node than the node running this Python function, which may have different info

    global _global_values
    if _global_values is None:
        _global_values = {}
        _global_values["hostname"] = socket.gethostname()
        _global_values["memory"] = round(psutil.virtual_memory().available / (1024 ** 3), 3)
        _global_values["username"] = getpass.getuser()

        # Work through VMs and logical cores.
        if hasattr(psutil.Process(), "cpu_affinity"):
            cpu_cnt = len(psutil.Process().cpu_affinity())
        else:
            cpu_cnt = psutil.cpu_count(logical=False)
            if cpu_cnt is None:
                cpu_cnt = psutil.cpu_count(logical=True)

        _global_values["ncores"] = cpu_cnt
        _global_values["nnodes"] = 1

        _global_values["cpuinfo"] = cpuinfo.get_cpu_info()
        try:
            _global_values["cpu_brand"] = _global_values["cpuinfo"]["brand_raw"]
        except KeyError:
            # Remove this if py-cpuinfo is pinned to >=6.0.0
            _global_values["cpu_brand"] = _global_values["cpuinfo"]["brand"]

    if key is None:
        return _global_values.copy()
    else:
        return _global_values[key] 
開發者ID:MolSSI,項目名稱:QCEngine,代碼行數:38,代碼來源:config.py

示例11: vendor

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def vendor():
                return cpuinfo.get_cpu_info()['vendor_id'] 
開發者ID:Pardus-LiderAhenk,項目名稱:ahenk,代碼行數:4,代碼來源:system.py

示例12: brand

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def brand():
                return cpuinfo.get_cpu_info()['brand'] 
開發者ID:Pardus-LiderAhenk,項目名稱:ahenk,代碼行數:4,代碼來源:system.py

示例13: hz_advertised

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def hz_advertised():
                return cpuinfo.get_cpu_info()['hz_advertised'] 
開發者ID:Pardus-LiderAhenk,項目名稱:ahenk,代碼行數:4,代碼來源:system.py

示例14: hz_actual

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def hz_actual():
                return cpuinfo.get_cpu_info()['hz_actual'] 
開發者ID:Pardus-LiderAhenk,項目名稱:ahenk,代碼行數:4,代碼來源:system.py

示例15: bit

# 需要導入模塊: import cpuinfo [as 別名]
# 或者: from cpuinfo import get_cpu_info [as 別名]
def bit():
                return cpuinfo.get_cpu_info()['bits'] 
開發者ID:Pardus-LiderAhenk,項目名稱:ahenk,代碼行數:4,代碼來源:system.py


注:本文中的cpuinfo.get_cpu_info方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。