Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz";
p.StartInfo.Arguments = "script -S server -U sa -P sys123 -d Newone " c:\\Newone.sql ";
In above code how can i messuring the process time or time for executing that query
p.Start();

Manikavelu VelayuthamRank #413 · 6K reputationPosted Mar 11, 2011, 1:58 AM EST
Stopwatch timer = new Stopwatch();
timer.Start();
...
...
timer.Stop();
MessageBox.Show("Elapsed: "+ timer.Elapsed);
MessageBox.Show("In milliseconds: "+ timer.ElapsedMilliseconds);
MessageBox.Show("In timer ticks: "+ timer.ElapsedTicks);
The above code is used to find out the execution time in .NET
VulpesRank #55 · 29.2K reputationPosted Mar 11, 2011, 2:06 AM EST
// create private field
private DateTime start;
// ...
Process p = new Process();
p.StartInfo.FileName = @"C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\sqlpubwiz";
p.StartInfo.Arguments = "script -S server -U sa -P sys123 -d Newone " c:\\Newone.sql ";
p.EnableRaisingEvents = true;
p.Exited += Process_Exited;
start = DateTime.Now;
p.Start();
private void Process_Exited(object sender, System.EventArgs e)
{
Process p = (Process)sender;
TimeSpan elapsed = p.ExitTime - start;
MessageBox.Show("The process ran for {0} milliseconds", elapsed.TotalMilliseconds);
}
Suthish NairRank #92 · 22.8K reputationPosted Mar 12, 2011, 8:47 AM EST
Sam HobbsRank #107 · 20.5K reputationPosted Mar 12, 2011, 10:14 AM EST
VulpesRank #55 · 29.2K reputationPosted Mar 12, 2011, 10:56 AM EST