How To Profile A Multiple Process Executable

How To Profile A Multiple Process Executable



Introduction

This example will show you how simple it is to profile an application that spawns multiple executable's. These steps are also applicable for use with both “Coverage” and “Performance” Analysis. It is also important to mention that the duration of the session is directly related to the duration of the parent process.  Meaning, during the profiling session, a separate performance or coverage file will be generated for each targeted child process.  However, the session file for the parent process will get generated upon the termination of its process.

The overall architecture of the application used for this demonstration is fairly simple and straightforward, developed only to demonstrate the mechanics of the process. The parent process was written in C# and the child processes, a total of three, were written in Native C++. 

Steps

1.  Customize your .xml configuration file (samples of configuration files can be found @ C:\Program Files (x86)\Micro Focus\DevPartner Studio\Analysis\SampleConfigs)

XML Attributes of note:


SESSION_DIR- Specifies the folder that your generated session file will be saved into.  If this attribute is not set, the session file generation will default to “My Documents”

SESSION_FILENAME
– Specifies the customized name of the session file generated.  By default, the executable name followed by a number will be appended to the session file, e.g., myApplication1.dpcov.

NM_METHOD_GRANULARITY – This is an optional attribute used to set data collection to method-level, line-level is used by default.

EXCLUDE_SYSTEM_DLLS – This is an optional attribute used to exclude system images.

FORCE_PROFILING – This is an optional attribute used to force the profiling of a executable written with C/C++ instrumentation or managed code.

This is only but a small sample of the attributes available to you for customizing your configuration file based on your needs. In addition to the xml attribute data, there are a number of switches that allow you to change the analysis type, how data is collected, and addressing session specific needs. For a more in-depth overview consult the DevPartner Studio Users Guide (Micro Focus, 2013, p. 109)

Here is a sample of the xml file used for this example.  A number of the available attributes were omitted for sake of simplicity. There are numerous xml attributes available for custom configurations. 

XML Configuration Example

<?xml version="1.0" ?>

<!--   -->

<ProductConfiguration xmlns="http://www.microfocus.com/products">  
<RuntimeAnalysis Type="Coverage" />

 <Targets>     

<!- Parent Process ->

<Process CollectData="true" Spawn="true" Primary="true" NoWaitForCompletion="false" NewConsole="false">                         <AnalysisOptions NM_METHOD_GRANULARITY="0" NM_ALLOW_INLINING="1" SESSION_FILENAME=""    SESSION_DIR="C:\_source\projects\vs2010\CommunityArticle3\profileData"/>    <Path>C:\_source\projects\vs2010\CommunityArticle3\CommunityArticle3.exe</Path>
     <WorkingDirectory>C:\_source\projects\vs2010\CommunityArticle3\</WorkingDirectory>    
  </Process>

<!- Child Process ->

  <Process CollectData="true" Spawn="true" NoWaitForCompletion="false" NewConsole="false">                         <AnalysisOptions NM_METHOD_GRANULARITY="0" NM_ALLOW_INLINING="1" SESSION_FILENAME=""                          SESSION_DIR="C:\_source\projects\vs2010\CommunityArticle3\profileData"/>    <Path>C:\_source\projects\vs2010\CommunityArticle3\sampleAppOne.exe</Path>       <WorkingDirectory>C:\_source\projects\vs2010\CommunityArticle3\</WorkingDirectory>    
  </Process>

<!- Child Process ->

  <Process CollectData="true" Spawn="true" NoWaitForCompletion="false" NewConsole="false">                         <AnalysisOptions NM_METHOD_GRANULARITY="0" NM_ALLOW_INLINING="1" SESSION_FILENAME=""                          SESSION_DIR="C:\_source\projects\vs2010\CommunityArticle3\profileData"/>    <Path>C:\_source\projects\vs2010\CommunityArticle3\sampleAppTwo.exe</Path>       <WorkingDirectory>C:\_source\projects\vs2010\CommunityArticle3\</WorkingDirectory>
   </Process>

<!- Child Process ->

  <Process CollectData="true" Spawn="true" NoWaitForCompletion="false" NewConsole="false">                         <AnalysisOptions NM_METHOD_GRANULARITY="0" NM_ALLOW_INLINING="1" SESSION_FILENAME=""                          SESSION_DIR="C:\_source\projects\vs2010\CommunityArticle3\profileData"/>    <Path>C:\_source\projects\vs2010\CommunityArticle3\sampleAppThree.exe</Path>       <WorkingDirectory>C:\_source\projects\vs2010\CommunityArticle3\</WorkingDirectory>
   </Process>  

</Targets>
</ProductConfiguration>

 

2. Calling your configuration file from the Command Line

*For convenience and ease of use, placing the DPAnalysis.exe executable in the system “path” is desirable.

From the command line, invoke DPAnalysis: C:\ [ Application Process Directory ] \ dpanalysis /config NameOfYourConfigFile.xml



Once executed, a session dialog box will appear allowing you to control the session, e.g., pausing, taking additional snapshots, and or terminating the session.



For this example, the parent process is named “CommunityArticle3”.  The parent process will spawn three additional processes, "sampleAppOne", "sampleAppTwo", and "sampleAppThree".  

Upon the completion of each child process a session file is generated.

(SampleAppOne.exe – Session File)

(SampleAppTwo.exe – Session File) 



(SampleAppThree.exe – Session File)



A session file is generated for the parent process after termination.


(CommunityArticle3.exe – Session File)


The session file data for each profiled process will remain open.  Allowing you the option to print the coverage data, view the profiled source code, and or export to ether XML or CSV formats.



Here is an example of the coverage data for one of the processes profiled in this example.





To learn more about profiling for Coverage or Performance Analysis, consult the DevPartner Studio User Guide (Micro Focus, 2013, p. 109),

 



References

Micro Focus (2013). Understanding DevPartner -Chapter 4 “Automatic Code Coverage”(109).

Labels (1)

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
2 of 2
Last update:
‎2020-01-23 21:43
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.