Example #1
0
class TargetLauncher(object):
    """
  If a target application is running remotely, configure the remote environment on the remote host
  Create and launch the target application and xpedite application
  """
    def __init__(self, binary, profileInfo, remote=None):
        """
    Create and enter a temp directory which will be used to stored xpedite application information
    If a target application is being run remotely, TargetLauncher will create the temp directory on the remote host
    """
        import tempfile
        from xpedite.profiler.app import XpediteApp
        if remote:
            self.tempDir = remote.connection.modules.tempfile.mkdtemp()
            remote.connection.modules.os.chdir(self.tempDir)
        else:
            self.tempDir = tempfile.mkdtemp()
            os.chdir(self.tempDir)
        args = [binary, '-c', '0']
        self.targetApp = buildTargetApp(args, remote)
        appInfo = os.path.join(self.tempDir, 'xpedite-appinfo.txt')
        self.xpediteApp = XpediteApp(profileInfo.appName, profileInfo.appHost,
                                     appInfo)

    def __enter__(self):
        self.targetApp.__enter__()
        self.xpediteApp.start()
        return self

    def __exit__(self, objType, value, traceback):
        self.xpediteApp.stop()
        self.targetApp.__exit__(None, None, None)
Example #2
0
 def __init__(self,
              binary,
              profileInfo,
              txnCount,
              threadCount,
              workspace,
              remote=None):
     """
 Create and enter a temp directory which will be used to stored xpedite application information
 If a target application is being run remotely, TargetLauncher will create the temp directory on the remote host
 """
     import tempfile
     from xpedite.profiler.app import XpediteApp
     if remote:
         self.tempDir = remote.connection.modules.tempfile.mkdtemp()
         remote.connection.modules.os.chdir(self.tempDir)
     else:
         self.tempDir = tempfile.mkdtemp()
         os.chdir(self.tempDir)
     args = ([
         binary, '-c', '0', '-m',
         str(threadCount), '-t',
         str(txnCount)
     ])
     self.targetApp = buildTargetApp(args, remote)
     appInfo = os.path.join(self.tempDir, 'xpedite-appinfo.txt')
     self.xpediteApp = XpediteApp(profileInfo.appName,
                                  profileInfo.appHost,
                                  appInfo,
                                  workspace=workspace)
Example #3
0
  def record(profileInfoPath, benchmarkPath=None, duration=None, heartbeatInterval=None,
      samplesFileSize=None, cprofile=None, profileName=None, verbose=None):
    """
    Records an xpedite profile using the supplied parameters

    :param profileInfoPath: Path to profile info module
    :type profileInfoPath: str
    :param benchmarkPath: Path to persist profile data for benchmarking
    :type benchmarkPath: str
    :param duration: Profile duration - The session is automatically terminated after elapse
                     of duration seconds (Default value = None)
    :type duration: int
    :param heartbeatInterval: Heartbeat interval for profiler's tcp connection
    :type heartbeatInterval: int
    :param samplesFileSize: Max size of data files used to store samples
    :type samplesFileSize: int
    :param cprofile: Handle to capture self profile Xpedite report generation code (Default value = None)
    :type cprofile: C{xpedite.selfProfile.CProfile}
    :param profileName: Name of the profile report
    :type profileName: str
    :param verbose: Flag to enable, verbose logging
    :type verbose: bool
    """
    if verbose:
      enableVerboseLogging()
    profileInfo = loadProfileInfo(profileInfoPath)
    validateBenchmarkPath(benchmarkPath)
    app = XpediteApp(profileInfo.appName, profileInfo.appHost, profileInfo.appInfo)
    with app:
      reportName = buildReportName(profileInfo.appName, profileName)
      report = Profiler.profile(
        app, profileInfo, reportName, benchmarkPath, False, heartbeatInterval=heartbeatInterval,
        samplesFileSize=samplesFileSize, duration=duration, cprofile=cprofile
      )
    return profileInfo, report
Example #4
0
    def generate(appInfoPath, hostname=None):
        """
    Attaches to application and generates default profile info

    :param appInfoPath: Path to app info module
    :type appInfoPath: str
    :param hostname: Name of the host running the target process
    :type hostname: str
    """
        hostname = hostname if hostname else 'localhost'
        app = XpediteApp('app', hostname, appInfoPath)
        probes = _loadProbes(app)
        if probes:
            from xpedite.profiler.profileInfoGenerator import ProfileInfoGenerator
            appInfoAbsolutePath = os.path.abspath(appInfoPath)
            profilerPath = os.path.abspath(
                os.path.join(__file__, '../../../../bin/xpedite'))
            return ProfileInfoGenerator(app.executableName, hostname,
                                        appInfoAbsolutePath, probes,
                                        profilerPath).generate()
        else:
            LOGGER.error(
                'failed to generate profile_info.py. cannot locate probes in app. Have you instrumented any ?\n'
            )
        return None
Example #5
0
 def makeXpediteApp(self, workspace):
     """
 Create an Xpedite live profiling app
 """
     from xpedite.profiler.app import XpediteApp
     return XpediteApp(self.appName,
                       self.appHost,
                       self.appInfo,
                       workspace=workspace)
Example #6
0
  def probes(profileInfoPath):
    """
    Attaches to application and loads probe data

    :param profileInfoPath: Path to profile info module
    :type profileInfoPath: str
    """
    profileInfo = loadProfileInfo(profileInfoPath)
    app = XpediteApp('app', profileInfo.appHost, profileInfo.appInfo)
    return _loadProbes(app), profileInfo