Skip to content

Commit 161b827

Browse files
authored
Merge pull request #1 from magic5644/FeatureParallelism
add watch to get processing time
2 parents 5ecee96 + edbdf66 commit 161b827

File tree

3 files changed

+24
-21
lines changed

3 files changed

+24
-21
lines changed

CodeLineCounter.Tests/CyclomaticComplexityCalculatorTests.cs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ public void TestCalculateComplexity()
1111
{
1212
// Arrange
1313
var code = @"
14-
using System;
15-
namespace TestNamespace
16-
{
1714
public class TestClass
1815
{
1916
public void TestMethod()
@@ -22,7 +19,6 @@ public void TestMethod()
2219
for (int i = 0; i < 10; i++) {}
2320
}
2421
}
25-
}
2622
";
2723
var tree = CSharpSyntaxTree.ParseText(code);
2824
var compilation = CSharpCompilation.Create("Test", new[] { tree });

CodeLineCounter/Program.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using CodeLineCounter.Services;
22
using CodeLineCounter.Utils;
3+
using System.Diagnostics;
34
using System;
45
using System.IO;
56

@@ -49,12 +50,18 @@ static void Main(string[] args)
4950
Console.Write("Choose a solution to analyze (enter the number): ");
5051
if (int.TryParse(Console.ReadLine(), out int choice) && choice > 0 && choice <= solutionFiles.Count)
5152
{
53+
// Add watch
54+
var timer = new Stopwatch();
55+
timer.Start();
5256
string solutionPath = solutionFiles[choice - 1];
5357
string solutionFilename = Path.GetFileName(solutionPath);
5458
string csvFilePath = solutionFilename + "-" + "CodeMetrics.csv"; // You can modify this path according to your needs
5559

5660
var analyzer = new CodeAnalyzer();
5761
var (metrics, projectTotals, totalLines, totalFiles) = analyzer.AnalyzeSolution(solutionPath);
62+
timer.Stop();
63+
TimeSpan timeTaken = timer.Elapsed;
64+
string processingTime = "Time taken: " + timeTaken.ToString(@"m\:ss\.fff");
5865

5966
if (verbose)
6067
{
@@ -72,8 +79,9 @@ static void Main(string[] args)
7279
Console.WriteLine($"Total lines of code: {totalLines}");
7380

7481
// Export the data to CSV format
75-
CsvExporter.ExportToCsv(csvFilePath, metrics, projectTotals, totalLines);
82+
CsvExporter.ExportToCsv(csvFilePath, metrics.ToList(), projectTotals, totalLines);
7683
Console.WriteLine($"The data has been exported to {csvFilePath}");
84+
Console.WriteLine(processingTime);
7785
}
7886
else
7987
{

README.md

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -82,25 +82,24 @@ The program generates a CSV file named `CodeMetrics.csv` containing the followin
8282
## Example Output
8383

8484
```csv
85-
Project,ProjectPath,Namespace,FileName,FilePath,LineCount,CyclomaticComplexity
86-
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter,Program.cs,CodeLineCounter\Program.cs,56,7
87-
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Models,NamespaceMetrics.cs,CodeLineCounter\Models\NamespaceMetrics.cs,13,1
88-
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,NamespaceMetrics,CodeAnalyzer.cs,CodeLineCounter\Services\CodeAnalyzer.cs,101,10
89-
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Services,CyclomaticComplexityCalculator.cs,CodeLineCounter\Services\CyclomaticComplexityCalculator.cs,65,12
85+
Project,ProjectPath,Namespace,FileName,FilePath,LineCount,CyclomaticComplexity,
9086
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Utils,CsvExporter.cs,CodeLineCounter\Utils\CsvExporter.cs,32,5
87+
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter,Program.cs,CodeLineCounter\Program.cs,71,11
88+
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Services,CyclomaticComplexityCalculator.cs,CodeLineCounter\Services\CyclomaticComplexityCalculator.cs,65,12
89+
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Models,NamespaceMetrics.cs,CodeLineCounter\Models\NamespaceMetrics.cs,13,1
90+
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,NamespaceMetrics,CodeAnalyzer.cs,CodeLineCounter\Services\CodeAnalyzer.cs,142,8
9191
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Utils,FileUtils.cs,CodeLineCounter\Utils\FileUtils.cs,33,3
92-
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter,Total,.\CodeLineCounter,54,0
93-
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Models,Total,.\CodeLineCounter,13,0
94-
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Services,Total,.\CodeLineCounter,114,0
95-
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,NamespaceMetrics,Total,.\CodeLineCounter,46,0
9692
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Utils,Total,.\CodeLineCounter,62,0
97-
CodeLineCounter,Total,,,,300,
98-
CodeLineCounter.Tests,CodeLineCounter.Tests\CodeLineCounter.Tests.csproj,CodeLineCounter.Tests,CodeAnalyzerTests.cs,CodeLineCounter.Tests\CodeAnalyzerTests.cs,19,1
99-
CodeLineCounter.Tests,CodeLineCounter.Tests\CodeLineCounter.Tests.csproj,TestNamespace,CyclomaticComplexityCalculatorTests.cs,CodeLineCounter.Tests\CyclomaticComplexityCalculatorTests.cs,32,1
100-
CodeLineCounter.Tests,CodeLineCounter.Tests\CodeLineCounter.Tests.csproj,CodeLineCounter.Tests,Total,.\CodeLineCounter.Tests,27,0
101-
CodeLineCounter.Tests,CodeLineCounter.Tests\CodeLineCounter.Tests.csproj,TestNamespace,Total,.\CodeLineCounter.Tests,21,0
102-
CodeLineCounter.Tests,Total,,,,51,
103-
Total,,,,,351,
93+
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter,Total,.\CodeLineCounter,67,0
94+
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Models,Total,.\CodeLineCounter,13,0
95+
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,NamespaceMetrics,Total,.\CodeLineCounter,101,0
96+
CodeLineCounter,CodeLineCounter\CodeLineCounter.csproj,CodeLineCounter.Services,Total,.\CodeLineCounter,100,0
97+
CodeLineCounter,Total,,,,356,
98+
CodeLineCounter.Tests,CodeLineCounter.Tests\CodeLineCounter.Tests.csproj,CodeLineCounter.Tests,CodeAnalyzerTests.cs,CodeLineCounter.Tests\CodeAnalyzerTests.cs,68,1
99+
CodeLineCounter.Tests,CodeLineCounter.Tests\CodeLineCounter.Tests.csproj,CodeLineCounter.Tests,CyclomaticComplexityCalculatorTests.cs,CodeLineCounter.Tests\CyclomaticComplexityCalculatorTests.cs,54,1
100+
CodeLineCounter.Tests,CodeLineCounter.Tests\CodeLineCounter.Tests.csproj,CodeLineCounter.Tests,Total,.\CodeLineCounter.Tests,118,0
101+
CodeLineCounter.Tests,Total,,,,122,
102+
Total,,,,,478,
104103
```
105104

106105
## Project Structure

0 commit comments

Comments
 (0)