博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
leetcode 服务器环境
阅读量:4673 次
发布时间:2019-06-09

本文共 4945 字,大约阅读时间需要 16 分钟。

今天因为好奇扒取了 leetcode 服务器端的开发环境。


  • 方法:随便找个题,利用stdout 输出系统信息,如下:

    1574881-20190403103025179-1026210700.png

  • 完整信息如下:

    === os information ===
    Linux version 4.4.0-131-generic (buildd@lgw01-amd64-015) (gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.10) ) #157-Ubuntu SMP Thu Jul 12 15:51:36 UTC 2018
    === cpu infomation ===
    processor : 0
    vendor_id : GenuineIntel
    cpu family : 6
    model : 79
    model name : Intel(R) Xeon(R) CPU E5-2697A v4 @ 2.60GHz
    stepping : 1
    microcode : 0x1
    cpu MHz : 2599.996
    cache size : 40960 KB
    physical id : 0
    siblings : 1
    core id : 0
    cpu cores : 1
    apicid : 0
    initial apicid : 0
    fpu : yes
    fpu_exception : yes
    cpuid level : 13
    wp : yes
    flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single kaiser tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt
    bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
    bogomips : 5199.99
    clflush size : 64
    cache_alignment : 64
    address sizes : 40 bits physical, 48 bits virtual
    power management:
    processor : 1
    vendor_id : GenuineIntel
    cpu family : 6
    model : 79
    model name : Intel(R) Xeon(R) CPU E5-2697A v4 @ 2.60GHz
    stepping : 1
    microcode : 0x1
    cpu MHz : 2599.996
    cache size : 40960 KB
    physical id : 1
    siblings : 1
    core id : 0
    cpu cores : 1
    apicid : 1
    initial apicid : 1
    fpu : yes
    fpu_exception : yes
    cpuid level : 13
    wp : yes
    flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon rep_good nopl eagerfpu pni pclmulqdq vmx ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single kaiser tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm rdseed adx smap xsaveopt
    bugs : cpu_meltdown spectre_v1 spectre_v2 spec_store_bypass
    bogomips : 5199.99
    clflush size : 64
    cache_alignment : 64
    address sizes : 40 bits physical, 48 bits virtual
    power management:
    === memory information ===
    MemTotal: 4046404 kB
    MemFree: 1329068 kB
    MemAvailable: 1974100 kB
    Buffers: 159648 kB
    Cached: 597080 kB
    SwapCached: 29884 kB
    Active: 1286924 kB
    Inactive: 602876 kB
    Active(anon): 657084 kB
    Inactive(anon): 515256 kB
    Active(file): 629840 kB
    Inactive(file): 87620 kB
    Unevictable: 3652 kB
    Mlocked: 3652 kB
    SwapTotal: 524284 kB
    SwapFree: 3020 kB
    Dirty: 12 kB
    Writeback: 0 kB
    AnonPages: 1107024 kB
    Mapped: 44892 kB
    Shmem: 36728 kB
    Slab: 720068 kB
    SReclaimable: 215152 kB
    SUnreclaim: 504916 kB
    KernelStack: 4848 kB
    PageTables: 9472 kB
    NFS_Unstable: 0 kB
    Bounce: 0 kB
    WritebackTmp: 0 kB
    CommitLimit: 2547484 kB
    Committed_AS: 2099816 kB
    VmallocTotal: 34359738367 kB
    VmallocUsed: 0 kB
    VmallocChunk: 0 kB
    HardwareCorrupted: 0 kB
    AnonHugePages: 0 kB
    CmaTotal: 0 kB
    CmaFree: 0 kB
    HugePages_Total: 0
    HugePages_Free: 0
    HugePages_Rsvd: 0
    HugePages_Surp: 0
    Hugepagesize: 2048 kB
    DirectMap4k: 3686380 kB
    DirectMap2M: 507904 kB
    DirectMap1G: 0 kB

  • 源代码(获取系统信息的代码):
#include 
#include
#include
// mostly need to read the linux config files to get system info // ---- get os info ---- //void getOsInfo(){ FILE *fp = fopen("/proc/version", "r"); if(NULL == fp) printf("failed to open version\n"); char szTest[1000] = {0}; while(!feof(fp)) { memset(szTest, 0, sizeof(szTest)); fgets(szTest, sizeof(szTest) - 1, fp); // leave out \n printf("%s", szTest); } fclose(fp);}// ---- get cpu info ---- //void getCpuInfo(){ FILE *fp = fopen("/proc/cpuinfo", "r"); if(NULL == fp) printf("failed to open cpuinfo\n"); char szTest[1000] = {0}; // read file line by line while(!feof(fp)) { memset(szTest, 0, sizeof(szTest)); fgets(szTest, sizeof(szTest) - 1, fp); // leave out \n printf("%s", szTest); } fclose(fp);} // ---- get memory info ---- //void getMemoryInfo(){ FILE *fp = fopen("/proc/meminfo", "r"); if(NULL == fp) printf("failed to open meminfo\n"); char szTest[1000] = {0}; while(!feof(fp)) { memset(szTest, 0, sizeof(szTest)); fgets(szTest, sizeof(szTest) - 1, fp); printf("%s", szTest); } fclose(fp);} // ---- get harddisk info ---- //#include
#include
#include
void lin(){ printf("=== os information ===\n"); getOsInfo(); printf("=== cpu infomation ===\n"); getCpuInfo(); printf("=== memory information ===\n"); getMemoryInfo();}class Solution {public: vector
> threeSum(vector
& nums) { lin();//选哪个题无所谓,调用一遍lin()就行,此处是选的3Sum这题 vector
> t; return t; }};

转载于:https://www.cnblogs.com/yhjd/p/10647203.html

你可能感兴趣的文章
【poj3375】 Network Connection
查看>>
【uoj207】 共价大爷游长沙
查看>>
windows server2003 xp化
查看>>
开始→运行(cmd)命令大全
查看>>
修改mysql数据库名称
查看>>
java中四种引用类型
查看>>
SharePoint 2007 "Select People and Groups"中搜索不到其他Domain账户的问题[已解决]
查看>>
yafu安装使用方法以及mismatched parens解决方法
查看>>
浅谈压缩感知(十六):感知矩阵之RIP
查看>>
java中使用字符(字节)读取文本内容
查看>>
mysql联表查询
查看>>
day01
查看>>
2017/2/27
查看>>
全编译报错
查看>>
梯度下降算法
查看>>
高性能JavaScript(您值得一看)
查看>>
Motan:目录结构
查看>>
Docker管理工具-Swarm部署记录
查看>>
待整理
查看>>
LINUX 循环fork()
查看>>