Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
private int Count(string dir, string[] mask)
{
countblanklin=0;

countcommentlines = 0;
this.statusBar.Text = dir;
this.statusBar.Update();

int totalCount = 0;
string[] dirs = Directory.GetDirectories(dir);


string dirName = dir.Substring(this.startPath.Length);
foreach (string pattern in mask)
{
string[] filenames = Directory.GetFiles(dir, pattern);
foreach (string file in filenames)
{
if (!running)
return 0;

int count = CountFile(file);
if (count > 0)
{
string name = Path.GetFileName(file);
TreeNode node = new TreeNode(name + " (" + count +")");
node.ImageIndex = 1;
node.SelectedImageIndex = 1;
listBox1.Items.Add(node);
totalCount += count;

FileEntry entry = new FileEntry(name, dirName, count);
this.files.Add(entry);
}
}
}
return totalCount;
}

private int CountFile(string path)
{
int count = 0;
countblanklin=0;
countcommentlines=0;
countifs=0;
countelse=0;
StatementCoverage = 0;
Brain b = new Brain();
try
{
StreamReader reader = new StreamReader(path);
String s;
do
{
s = reader.ReadLine();
if (s != null)
{
count++;
bool a = b.IsSource(s);

if (b.CountIfs) countifs++;
if ((b._isinsideif || b._isinsideelse) && (s.Trim().StartsWith(@"}") || s.Trim().StartsWith(@"else"))) b._isinsideif = false;
if ((b._isinsideif || b._isinsideelse) && (s.Trim().StartsWith(@"}"))) b._isinsideelse = false;
if ((b._isinsideif || b._isinsideelse) && !((s.Trim().StartsWith(@"if")) || (s.Trim().StartsWith(@"else"))))
StatementCoverage++;


if (b.CountElae) countelse++;
if (b.CountMultiLineComments)
countcommentlines++;
}
} while (s != null);
reader.Close();
}
catch (IOException)
{
}

return count;
}
_____________________________________________
private void cmdCount_Click(object sender, System.EventArgs e)
{

DateTime then = DateTime.Now;
System.Diagnostics.Process.GetCurrentProcess().ProcessorAffinity = (System.IntPtr)1;
TimeSpan diff = DateTime.Now - then;
} 
String.Format("{0:00}:{1:00}:{2:00}.{3:00}", (diff.Hours), diff.Minutes, diff.Sec


What I have tried:

tried to find online tools that calculate the time complexity but couldnt find any ,
can anyone help me finding a tool
or calculate it manually
Posted
Updated 11-Mar-16 0:19am

The phrase "I want to calculate..." does not work well with the "find me a tool" and "or calculate it for me" bits.
We are not not here to do your work for you.
If you want someone to do your job for you, you have to pay - I suggest you go to Freelancer.com and ask there.

But be aware: you get what you pay for. Pay peanuts, get monkeys.

Alternatively, give it a try yourself, and see how far you get. If you meet a specific problem, then ask about that. But nobody here is going to sit down and work out the time complexity of code for yoU!
 
Share this answer
 
I would use .NET class StopWatch here you can find anything you need
Classe Stopwatch (System.Diagnostics)[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900