libc = ctypes.cdll.msvcrt  
  handleMax = libc._getmaxstdio() # Query C run-time for maximum file handles

  # Anthony - we have chosen to use the default limit except for mobile
  # using None for socketMax here will trigger the default in 
  # benchmark_resources.py .
  if windows_api.MobileCE:
    socketMax = 64 / 2 # By default, only 64 sockets per app, both mobile
  else:
    socketMax = None

  # Measure random
  # SP: This test should now work on all systems. For failed tests, a string
  # describing the failure will be returned.
  try:
    randomMax = measure_random.measure_random()
  except measure_random.InvalidTimeMeasurementError, e:
    randomMax = str(e)


  # Measure the disk read write rate
  try:
    filewrite, fileread = measuredisk.main()
  except Exception, e:
    filewrite, fileread = str(e), str(e)



  resource_dict = {}

  resource_dict["cpu"] = numCPU
    # raised, it unlikely that the test would fail, but after seeing the
    # strange behavior of ulimit for events it seems best error on the side
    # of safety.
    try:
        maxfiles = get_filesopened() / 3
    except Exception, e:
        maxfiles = str(e)

    resource_dict["filesopened"] = maxfiles
    resource_dict["insockets"] = maxfiles
    resource_dict["outsockets"] = maxfiles

    # SP: this test should work on all systems now, but catch the exception just
    # in case.
    try:
        random_max = measure_random.measure_random()
    except measure_random.InvalidTimeMeasurementError, e:
        random_max = str(e)

    resource_dict["random"] = random_max

    # Measure the disk read write rate
    try:
        filewrite, fileread = measuredisk.main()
    except Exception, e:
        filewrite, fileread = str(e), str(e)

    resource_dict["filewrite"] = filewrite
    resource_dict["fileread"] = fileread

    # These resources are not measure in this script so a None
Example #3
0
def measure_resources():
    
  # First, get number of CPUs
  # SP: None is now reserved for unimplemented tests, and to differentiate
  # failed tests we return a string describing the error. At least in theory
  # this makes it easier to figure out what occurred.
  num_cpu = "unable to find number of CPUs"
  pipe = getShellPipe("sysctl hw.ncpu")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      num_cpu = int(line_s[1])
  pipe.close()

  # Next, get physical memory (RAM)
  phys_mem = "unable to find size of physical memory"
  pipe = getShellPipe("sysctl hw.physmem")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      phys_mem = int(line_s[1])
  pipe.close()

  """ 
  Anthony - this gives an answer much larger than what 
  can really be achieved. Rewriting to use ulimit instead.
  
  # Get max files open, defaulting to 1000
  # Make sure that 10% of the total system
  # is not more than the per process limit
  files_open = 1000
  files_open_per_proc = False
  files_open_total = False
  pipe = getShellPipe("sysctl kern.maxfiles")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      files_open_total = int(line_s[1])
  pipe.close()
  pipe = getShellPipe("sysctl kern.maxfilesperproc")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      files_open_per_proc = int(line_s[1])
  pipe.close()
  
  if files_open_per_proc and files_open_total:
    files_open = min(files_open_per_proc * 10, files_open_total)
  elif files_open_per_proc:
    files_open = 10 * files_open_per_proc
  elif files_open_total:
    files_open = files_open_total
  """
  # The ulimit command should only return a single value
  # for the max number of files open at a single time.
  pipe = getShellPipe("ulimit -n")
  for line in pipe:
    try:
      files_open = int(line)
    except ValueError:
      files_open = "bad value for max number of open files: " + str(line)


  # Get hard drive space
  disk_space = "unable to find hard drive size"
  pipe = getShellPipe("df -k .")
  seenFirstLine = False
  for line in pipe:
    if seenFirstLine:  
      line_s = re.split("\\s*", line)
      if len(line_s) >= 6 and line:
        disk_space = (int(line_s[3])) * 1024
    else:
      seenFirstLine = True
  pipe.close()

  # Get the max number of processes
  events = "unable to find max number of processes"
  pipe = getShellPipe("sysctl kern.maxprocperuid")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      events = int(line_s[1])
  pipe.close()

  # Get the max number of sockets
  maxsockets = "unable to find max number of sockets"
  pipe = getShellPipe("sysctl kern.ipc.maxsockets")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      maxsockets = int(line_s[1])
  pipe.close()
  
  if not isinstance(maxsockets, basestring):
    insocket = maxsockets / 2
    outsocket = maxsockets / 2
  else:
    insocket = maxsockets
    outsocket = maxsockets

  # Get the available bandwidth, defaulting to 100000
  """my_bandwidth = 100000
  server_ip = "128.208.1.137"
  try:
    my_bandwidth = bandwidth.get_bandwidth(server_ip)
  except:
    pass"""

  # SP: Measure random number generation rate, should work on all systems now
  try:
    random_max = measure_random.measure_random()
  except measure_random.InvalidTimeMeasurementError, e:
    random_max = str(e)
    threadMax = None

    libc = ctypes.cdll.msvcrt
    handleMax = libc._getmaxstdio(
    )  # Query C run-time for maximum file handles

    # Anthony - we have chosen to use the default limit except for mobile
    # using None for socketMax here will trigger the default in
    # benchmark_resources.py .
    socketMax = None

    # Measure random
    # SP: This test should now work on all systems. For failed tests, a string
    # describing the failure will be returned.
    try:
        randomMax = measure_random.measure_random()
    except measure_random.InvalidTimeMeasurementError, e:
        randomMax = str(e)

    # Measure the disk read write rate
    try:
        filewrite, fileread = measuredisk.main()
    except Exception, e:
        filewrite, fileread = str(e), str(e)

    resource_dict = {}

    resource_dict["cpu"] = numCPU
    resource_dict["memory"] = totalMem
    resource_dict["diskused"] = freeDisk
Example #5
0
def measure_resources():
    
  # First, get number of CPUs
  # SP: None is now reserved for unimplemented tests, and to differentiate
  # failed tests we return a string describing the error. At least in theory
  # this makes it easier to figure out what occurred.
  num_cpu = "unable to find number of CPUs"
  pipe = getShellPipe("sysctl hw.ncpu")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      num_cpu = int(line_s[1])
  pipe.close()

  # Next, get the machine's total physical memory (RAM) in bytes.
  # The expected output of the call to `sysctl` looks like this:
  # "hw.memsize: 8589934592"
  phys_mem = "unable to find size of physical memory"
  pipe = getShellPipe("sysctl hw.memsize")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      phys_mem = int(line_s[1])
  pipe.close()

  """ 
  Anthony - this gives an answer much larger than what 
  can really be achieved. Rewriting to use ulimit instead.
  
  # Get max files open, defaulting to 1000
  # Make sure that 10% of the total system
  # is not more than the per process limit
  files_open = 1000
  files_open_per_proc = False
  files_open_total = False
  pipe = getShellPipe("sysctl kern.maxfiles")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      files_open_total = int(line_s[1])
  pipe.close()
  pipe = getShellPipe("sysctl kern.maxfilesperproc")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      files_open_per_proc = int(line_s[1])
  pipe.close()
  
  if files_open_per_proc and files_open_total:
    files_open = min(files_open_per_proc * 10, files_open_total)
  elif files_open_per_proc:
    files_open = 10 * files_open_per_proc
  elif files_open_total:
    files_open = files_open_total
  """
  # The ulimit command should only return a single value
  # for the max number of files open at a single time.
  pipe = getShellPipe("ulimit -n")
  for line in pipe:
    try:
      files_open = int(line)
    except ValueError:
      files_open = "bad value for max number of open files: " + str(line)


  # Get hard drive space
  disk_space = "unable to find hard drive size"
  pipe = getShellPipe("df -k .")
  seenFirstLine = False
  for line in pipe:
    if seenFirstLine:  
      line_s = re.split("\\s*", line)
      if len(line_s) >= 6 and line:
        disk_space = (int(line_s[3])) * 1024
    else:
      seenFirstLine = True
  pipe.close()

  # Get the max number of processes
  events = "unable to find max number of processes"
  pipe = getShellPipe("sysctl kern.maxprocperuid")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      events = int(line_s[1])
  pipe.close()

  # Get the max number of sockets, or use a sane default on machines where 
  # this sysctl key is missing (SeattleTestbed/resource#5).
  maxsockets = 512
  pipe = getShellPipe("sysctl kern.ipc.maxsockets")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      maxsockets = int(line_s[1])
  pipe.close()
  
  if not isinstance(maxsockets, basestring):
    insocket = maxsockets / 2
    outsocket = maxsockets / 2
  else:
    insocket = maxsockets
    outsocket = maxsockets

  # Get the available bandwidth, defaulting to 100000
  """my_bandwidth = 100000
  server_ip = "128.208.1.137"
  try:
    my_bandwidth = bandwidth.get_bandwidth(server_ip)
  except:
    pass"""

  # SP: Measure random number generation rate, should work on all systems now
  try:
    random_max = measure_random.measure_random()
  except measure_random.InvalidTimeMeasurementError, e:
    random_max = str(e)
def measure_resources():
  # First, get number of CPUs
  # SP: None is now reserved for unimplemented tests, and to differentiate
  # failed tests we return a string describing the error. At least in theory
  # this makes it easier to figure out what occurred.
  num_cpu = "unable to find number of CPUs"
  pipe = getShellPipe("sysctl hw.ncpu")
  
  for line in pipe:
    line_s = line.split(" ")
    
    if len(line_s) > 1:
      num_cpu = int(line_s[1])
  
  pipe.close()

  # Next, get the machine's total physical memory (RAM) in bytes.
  # The expected output of the call to `sysctl` looks like this:
  # "hw.memsize: 8589934592"
  phys_mem = "unable to find size of physical memory"
  pipe = getShellPipe("sysctl hw.memsize")
  
  for line in pipe:
    line_s = line.split(" ")
    
    if len(line_s) > 1:
      phys_mem = int(line_s[1])
  
  pipe.close()

  # The ulimit command should only return a single value
  # for the max number of files open at a single time.
  pipe = getShellPipe("ulimit -n")
  for line in pipe:
    try:
      files_open = int(line)
    
    except ValueError:
      files_open = "bad value for max number of open files: " + str(line)


  # Get hard drive space
  disk_space = "unable to find hard drive size"
  pipe = getShellPipe("df -k .")
  seenFirstLine = False
  
  for line in pipe:
    if seenFirstLine:  
      line_s = re.split("\\s*", line)
      if len(line_s) >= 6 and line:
        disk_space = (int(line_s[3])) * 1024
    
    else:
      seenFirstLine = True
  
  pipe.close()

  # Get the max number of processes
  events = "unable to find max number of processes"
  pipe = getShellPipe("sysctl kern.maxprocperuid")
  
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      events = int(line_s[1])
  pipe.close()

  # Get the max number of sockets, or use a sane default on machines where 
  # this sysctl key is missing (SeattleTestbed/resource#5).
  maxsockets = 512
  pipe = getShellPipe("sysctl kern.ipc.maxsockets")
  for line in pipe:
    line_s = line.split(" ")
    if len(line_s) > 1:
      maxsockets = int(line_s[1])
  pipe.close()
  
  if not isinstance(maxsockets, basestring):
    insocket = maxsockets / 2
    outsocket = maxsockets / 2
  
  else:
    insocket = maxsockets
    outsocket = maxsockets


  # SP: Measure random number generation rate, should work on all systems now
  try:
    random_max = measure_random.measure_random()
  except measure_random.InvalidTimeMeasurementError, e:
    random_max = str(e)
Example #7
0
    # raised, it unlikely that the test would fail, but after seeing the
    # strange behavior of ulimit for events it seems best error on the side
    # of safety.
    try:
        maxfiles = get_filesopened() / 3
    except Exception, e:
        maxfiles = str(e)

    resource_dict["filesopened"] = maxfiles
    resource_dict["insockets"] = maxfiles
    resource_dict["outsockets"] = maxfiles

    # SP: this test should work on all systems now, but catch the exception just
    # in case.
    try:
        random_max = measure_random.measure_random()
    except measure_random.InvalidTimeMeasurementError, e:
        random_max = str(e)

    resource_dict["random"] = random_max

    # Measure the disk read write rate
    try:
        filewrite, fileread = measuredisk.main()
    except Exception, e:
        filewrite, fileread = str(e), str(e)

    resource_dict["filewrite"] = filewrite
    resource_dict["fileread"] = fileread

    # These resources are not measure in this script so a None