nerdexam
Microsoft

70-516 · Question #186

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server 2008 database. The application contains two…

The correct answer is D. Stopwatch w1 = Stopwatch.StartNew(). A & C do not reset the stopwatch before running cmd2. B does not start the stopwatch after resetting the stopwatch Start() does not reset the stopwatch, whereas StartNew() will create a new instance of the Stop watch and initialise the elapsed time to Zero.

Deploying and Troubleshooting Data Access

Question

You use Microsoft Visual Studio 2010 and Microsoft .NET Framework 4.0 to create an application. The application connects to a Microsoft SQL Server 2008 database. The application contains two SqlCommand objects named cmd1 and cmd2. You need to measure the time required to execute each command. Which code segment should you use?

Options

  • AStopwatch w1 = new Stopwatch();
  • BStopwatch w1 = new Stopwatch();
  • CStopwatch w1 = Stopwatch.StartNew();
  • DStopwatch w1 = Stopwatch.StartNew();

How the community answered

(24 responses)
  • A
    13% (3)
  • B
    8% (2)
  • C
    4% (1)
  • D
    75% (18)

Explanation

A & C do not reset the stopwatch before running cmd2. B does not start the stopwatch after resetting the stopwatch Start() does not reset the stopwatch, whereas StartNew() will create a new instance of the Stop watch and initialise the elapsed time to Zero.

Topics

#Stopwatch#performance measurement#SqlCommand#timing

Community Discussion

No community discussion yet for this question.

Full 70-516 Practice