CPU Information on Linux and OS X

This is small blog post detailing how to obtain information on your CPU on Linux and Mac OSX. These commands give information such as the instruction set of the processor, the type of processor, the number of cores, number of CPUs, information about the caches etc.

Linux :

In Linux, the “proc” file system  is providing most of the important information on the system. It interfaces with the kernel to obtain these information and is mounted as “/proc” on most of the Unix machines. More information can be found here.

The command to obtain information is this one.

$ /proc/cpuinfo
1
$ /proc/cpuinfo

If using GCC to compile C programs, you might want to use the “-march=cpu-type” to optimise your compilation to your type of processor and it’s set of instructions, to do that you can use use the following command :

$ grep flags /proc/cpuinfo
1
$ grep flags /proc/cpuinfo

Another useful command on multiple linux distributions is this one :

$ lscpu
1
$ lscpu

The command try to display information on your CPU in a human readable format but do not include all the information available.

OS X  :

On OS X mountain lion and probably some other versions, the commands to use are a bit different, some general information about the system can be found by using the “system_profiler” command. This command includes some simple information on the system in use:

$ system_profiler
1
$ system_profiler

However more dedicated information can be found by using the “sysctl” command which is an interface to dynamically change system variables and obtain detailed informations on the system. This command is also present on BSD systems.

$ sysctl hw
1
$ sysctl hw

This command will give you the following type of output :

hw.ncpu: 4
hw.byteorder: 1234
hw.memsize: 8589934592
hw.activecpu: 4
hw.physicalcpu: 2
hw.physicalcpu_max: 2
hw.logicalcpu: 4
hw.logicalcpu_max: 4
hw.cputype: 7
hw.cpusubtype: 4
hw.cpu64bit_capable: 1
hw.cpufamily: 1463508716
hw.cacheconfig: 4 2 2 4 0 0 0 0 0 0
hw.cachesize: 8589934592 32768 262144 4194304 0 0 0 0 0 0
hw.pagesize: 4096
hw.busfrequency: 4800000000
hw.busfrequency_min: 4800000000
hw.busfrequency_max: 4800000000
hw.cpufrequency: 2800000000
hw.cpufrequency_min: 2800000000
hw.cpufrequency_max: 2800000000
hw.cachelinesize: 64
hw.l1icachesize: 32768
hw.l1dcachesize: 32768
hw.l2cachesize: 262144
hw.l3cachesize: 4194304
hw.tbfrequency: 1000000000
hw.packages: 1
hw.optional.floatingpoint: 1
hw.optional.mmx: 1
hw.optional.sse: 1
hw.optional.sse2: 1
hw.optional.sse3: 1
hw.optional.supplementalsse3: 1
hw.optional.sse4_1: 1
hw.optional.sse4_2: 1
hw.optional.x86_64: 1
hw.optional.aes: 1
hw.optional.avx1_0: 0
hw.optional.rdrand: 0
hw.optional.f16c: 0
hw.optional.enfstrg: 0
hw.cputhreadtype: 1
hw.machine = x86_64
hw.model = MacBookPro6,2
hw.ncpu = 4
hw.byteorder = 1234
hw.physmem = 2147483648
hw.usermem = 877899776
hw.pagesize = 4096
hw.epoch = 0
hw.vectorunit = 1
hw.busfrequency = 4294967295
hw.cpufrequency = 2800000000
hw.cachelinesize = 64
hw.l1icachesize = 32768
hw.l1dcachesize = 32768
hw.l2settings = 1
hw.l2cachesize = 262144
hw.l3settings = 1
hw.l3cachesize = 4194304
hw.tbfrequency = 1000000000
hw.memsize = 8589934592
hw.availcpu = 4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
hw.ncpu: 4
hw.byteorder: 1234
hw.memsize: 8589934592
hw.activecpu: 4
hw.physicalcpu: 2
hw.physicalcpu_max: 2
hw.logicalcpu: 4
hw.logicalcpu_max: 4
hw.cputype: 7
hw.cpusubtype: 4
hw.cpu64bit_capable: 1
hw.cpufamily: 1463508716
hw.cacheconfig: 4 2 2 4 0 0 0 0 0 0
hw.cachesize: 8589934592 32768 262144 4194304 0 0 0 0 0 0
hw.pagesize: 4096
hw.busfrequency: 4800000000
hw.busfrequency_min: 4800000000
hw.busfrequency_max: 4800000000
hw.cpufrequency: 2800000000
hw.cpufrequency_min: 2800000000
hw.cpufrequency_max: 2800000000
hw.cachelinesize: 64
hw.l1icachesize: 32768
hw.l1dcachesize: 32768
hw.l2cachesize: 262144
hw.l3cachesize: 4194304
hw.tbfrequency: 1000000000
hw.packages: 1
hw.optional.floatingpoint: 1
hw.optional.mmx: 1
hw.optional.sse: 1
hw.optional.sse2: 1
hw.optional.sse3: 1
hw.optional.supplementalsse3: 1
hw.optional.sse4_1: 1
hw.optional.sse4_2: 1
hw.optional.x86_64: 1
hw.optional.aes: 1
hw.optional.avx1_0: 0
hw.optional.rdrand: 0
hw.optional.f16c: 0
hw.optional.enfstrg: 0
hw.cputhreadtype: 1
hw.machine = x86_64
hw.model = MacBookPro6,2
hw.ncpu = 4
hw.byteorder = 1234
hw.physmem = 2147483648
hw.usermem = 877899776
hw.pagesize = 4096
hw.epoch = 0
hw.vectorunit = 1
hw.busfrequency = 4294967295
hw.cpufrequency = 2800000000
hw.cachelinesize = 64
hw.l1icachesize = 32768
hw.l1dcachesize = 32768
hw.l2settings = 1
hw.l2cachesize = 262144
hw.l3settings = 1
hw.l3cachesize = 4194304
hw.tbfrequency = 1000000000
hw.memsize = 8589934592
hw.availcpu = 4

As  you can see, the  command is displaying  specific informations such as the instruction set supported by your processor amongst many other information. For more information on the sysctl command use RTFM.

Have fun.

mac os lscpu 【转】的更多相关文章

  1. Xamarin+Prism开发详解四:简单Mac OS 虚拟机安装方法与Visual Studio for Mac 初体验

    Mac OS 虚拟机安装方法 最近把自己的电脑升级了一下SSD固态硬盘,总算是有容量安装Mac 虚拟机了!经过心碎的安装探索,尝试了国内外的各种安装方法,最后在youtube上找到了一个好方法. 简单 ...

  2. Mac OS 使用 Vagrant 管理虚拟机(VirtualBox)

    Vagrant(官网.github)是一款构建虚拟开发环境的工具,支持 Window,Linux,Mac OS,Vagrant 中的 Boxes 概念类似于 Docker(实质是不同的),你可以把它看 ...

  3. Mac OS、Ubuntu 安装及使用 Consul

    Consul 概念(摘录): Consul 是 HashiCorp 公司推出的开源工具,用于实现分布式系统的服务发现与配置.与其他分布式服务注册与发现的方案,比如 Airbnb 的 SmartStac ...

  4. 让 ASP.NET vNext 在 Mac OS 中飞呀飞。。。

    写在前面 阅读目录: 娓娓道来 Install ASP.NET vNext Command Line Tools 安装 Homebrew 使用 Homebrew,安装 KVM Install Subl ...

  5. Atitit mac os 版本 新特性 attilax大总结

    Atitit mac os 版本 新特性 attilax大总结 1. Macos概述1 2. 早期2 2.1. Macintosh OS (系统 1.0)  1984年2 2.2. Mac OS 7. ...

  6. 【转】[fix] Wireshark error: There are no interfaces on which a capture can be done. on Mac OS X

    I got the following error message when trying to open a network interface for capture using Wireshar ...

  7. Mac OS使用brew安装Nginx、MySQL、PHP-FPM的LAMP开发环境

    准备工作 新版的 Mac OS 内置了Apache 和 PHP,我的系统版本是OS X 10.9.3,可以通过以下命令查看Apache和PHP的版本号: httpd -v Server version ...

  8. 【转】windows环境下安装win8.1+Mac OS X 10.10双系统教程

    先要感谢远景论坛里的各位大神们的帖子  没有他们的分享我也不能顺利的装上Mac OS X 10.10! 写这篇随笔主要是为了防止自己遗忘,同时给大家分享下我的经验. 本教程适用于BIOS+MBR分区的 ...

  9. win10 Vmware12装mac os X10.11虚拟机教程

    1.下载安装VMware 12,具体教程在网上都能看见. 2.下载mac os的镜像,最好下载cdr格式的. 3.在导入虚拟机的时候,到选择客户机操作系统的时候,没有网上出现的Mac os,如下图所示 ...

随机推荐

  1. Android中ViewPager动态创建的ImageView铺满屏幕

    ImageView imageView=new ImageView(context); imageView.setScaleType(ScaleType.FIT_XY);//铺满屏幕

  2. sql 分析 依赖beanutils

    你还在为sql语句的拼接而烦恼吗? sql语句支持表达式了! package com.newland.bi.webservice.common.manage; import java.util.Arr ...

  3. 【译】x86程序员手册19-6.3.2数据访问的约束

    6.3.2 Restricting Access to Data  数据访问的约束 To address operands in memory, an 80386 program must load ...

  4. mysql常用命令介绍

    mysql适用于在Internet上存取数据,支持多种平台 1.主键:唯一标识表中每行的这个列,没有主键更新或删除表中的特定行很困难. 2.连接mysql可以用Navicat 要读取数据库中的内容先要 ...

  5. ARM处理器的寄存器,ARM与Thumb状态,7中运行模式

     ** ARM处理器的寄存器,ARM与Thumb状态,7中运行模式  分类: 嵌入式 ARM处理器工作模式一共有 7 种 : USR  模式    正常用户模式,程序正常执行模式 FIQ模式(Fast ...

  6. Java中面向对象三大特性之——多态

    多态的概述:  多态是继封装.继承之后,面向对象的第三大特性. 生活中,比如跑的动作,小猫.小狗和大象,跑起来是不一样的.再比如飞的动作,昆虫.鸟类和飞机,飞起来也是不一样的.可见,同一行为,通过不同 ...

  7. 类 Fabric 主机管理程序开发

    类 Fabric 主机管理程序开发:1. 运行程序列出主机组或者主机列表2. 选择指定主机或主机组3. 选择让主机或者主机组执行命令或者向其传输文件(上传/下载4. 充分使用多线程或多进程5. 不同主 ...

  8. UVALive 3026(KMP算法)

    UVALive 3026     KMP中next[]数组的应用: 题意:给出一个字符串,问该字符串每个前缀首字母的位置和该前缀的周期. 思路:裸KMP直接上就是了: 设该字符串为str,str字符串 ...

  9. SQL上门

    学习这个 介绍:SQL 是用于访问和处理数据库的标准的计算机语言.结构化化查询语言! SQL可以分为两大部分:数据操作语言(DML)和数据定义语言(DDL) 数据操作语言:select.update. ...

  10. Linux的安装教程

    CentOS 6 + VMWare: 资源:https://pan.baidu.com/s/1AA4gaMpaoVaMor-tRU-n7A  提取码:6e8r    ( 内附 VMWare 14 激活 ...