CMS 3D CMS Logo

cmsCpuInfo.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 #Little script to get the number of cpus (cores) in the machine one is running on:
3 #Information is parsed from /proc/cpuinfo file
4 import os
5 
7  cores=0
8  cpuinfo=open("/proc/cpuinfo","r")
9  if cpuinfo:
10  for line in cpuinfo.readlines():
11  for token in line.split():
12  if token == 'processor':
13  cores=cores+1;
14  return cores
15  else:
16  print "Could not open file /proc/cpuinfo!\n"
17  return NULL
18  #Further functions to parse other information will come (RAM, Cache etc)
def get_NumOfCores()
Definition: cmsCpuInfo.py:6