private bool ExportProfiles(PProfBuildSession pprofBuildSession, string outputDirectory)
        {
            var filename = new StringBuilder("StackSamples.");

            filename.Append(_appName);
            filename.Append('.');
            filename.Append(TimestampTag);
            filename.Append(".pprof");

            Stream outFileStream = OpenTimestampedFile(outputDirectory, filename.ToString());

            if (pprofBuildSession == null)
            {
                using (outFileStream)
                {
                    using (var outw = new StreamWriter(outFileStream, Encoding.UTF8))
                    {
                        outw.WriteLine("No profiles data available at this time.");
                    }
                }
            }
            else
            {
                Stream outs = ApplyGZip
                                ? new GZipStream(outFileStream, GZipCompressionLevel)
                                : outFileStream;
                using (outs)
                {
                    pprofBuildSession.WriteProfileToStream(outs);
                }
            }

            return(true);
        }
 public bool ExportProfiles(PProfBuildSession pprofBuildSession)
 {
     if (_isEnabled)
     {
         return(ExportProfiles(pprofBuildSession, _outputDirectory));
     }
     else
     {
         return(false);
     }
 }