Exemple #1
0
        public static void ParseStatusInfo(string logFilePath, out CloneDetectiveResultStatus status, out long usedMemory, out TimeSpan usedTime)
        {
            string logFileContent = File.ReadAllText(logFilePath);

            status     = CloneDetectiveResultStatus.Succeeded;
            usedMemory = 0;
            usedTime   = TimeSpan.Zero;

            Match statusMatch = Regex.Match(logFileContent, @"CD_STATUS\: (?<Status>[a-zA-Z]+)");
            Match memoryMatch = Regex.Match(logFileContent, @"CD_MEMORY\: (?<Memory>[0-9]+)");
            Match timeMatch   = Regex.Match(logFileContent, @"CD_TIME\: (?<Time>[0-9.:]+)");

            SkipToLastMatch(ref statusMatch);
            SkipToLastMatch(ref memoryMatch);
            SkipToLastMatch(ref timeMatch);

            if (statusMatch.Success)
            {
                status = (CloneDetectiveResultStatus)Enum.Parse(typeof(CloneDetectiveResultStatus), statusMatch.Groups["Status"].Value);
            }

            if (memoryMatch.Success)
            {
                usedMemory = Int64.Parse(memoryMatch.Groups["Memory"].Value, CultureInfo.InvariantCulture);
            }

            if (timeMatch.Success)
            {
                usedTime = TimeSpan.Parse(timeMatch.Groups["Time"].Value);
            }
        }
Exemple #2
0
 /// <summary>
 /// Writes the given status and stats to the log file.
 /// </summary>
 /// <param name="logWriter">The log file writer to write to.</param>
 /// <param name="status">The status to be written.</param>
 /// <param name="usedMemory">The memory usage to be written.</param>
 /// <param name="usedTime">The time to be written.</param>
 public static void WriteStatusInfo(TextWriter logWriter, CloneDetectiveResultStatus status, long usedMemory, TimeSpan usedTime)
 {
     logWriter.WriteLine();
     logWriter.WriteLine("**** Result ****");
     logWriter.WriteLine(String.Format(CultureInfo.InvariantCulture, "CD_STATUS: {0}", status));
     logWriter.WriteLine(String.Format(CultureInfo.InvariantCulture, "CD_MEMORY: {0}", usedMemory));
     logWriter.WriteLine(String.Format(CultureInfo.InvariantCulture, "CD_TIME: {0}", usedTime));
 }
Exemple #3
0
 /// <summary>
 /// Writes the given status and stats to the log file.
 /// </summary>
 /// <param name="logFilePath">The fully qualified path to the log file to write to.</param>
 /// <param name="status">The status to be written.</param>
 /// <param name="usedMemory">The memory usage to be written.</param>
 /// <param name="usedTime">The time to be written.</param>
 public static void WriteStatusInfo(string logFilePath, CloneDetectiveResultStatus status, long usedMemory, TimeSpan usedTime)
 {
     using (StreamWriter sw = new StreamWriter(logFilePath, true))
         WriteStatusInfo(sw, status, usedMemory, usedTime);
 }