Stop Method

Applies to TestComplete 15.47, last modified on January 20, 2023

Description

The StopWatch.Stop method stops timing and returns the number of milliseconds passed. To convert the number of passed milliseconds into a readable time format use the StopWatch.ToString routine.

Declaration

StopWatchObj.Stop()

StopWatchObj An expression, variable or parameter that specifies a reference to a StopWatch object
Result Integer

Applies To

The method is applied to the following object:

Result Value

The number of milliseconds passed.

Example

The following code snippet starts a test and measures how much time has been spent on its execution.

JavaScript, JScript

function Test()
{
  var StopWatch;
  StopWatch = HISUtils.StopWatch;
  // Starts the time counter
  StopWatch.Start();
  DoTest1();
  // Stops the time counter
  StopWatch.Stop();
  // Posts the passed time to the test log
  Log.Message("Test1 finished. Execution time: " + StopWatch.ToString());

}

Python

def Test():

  StopWatch = HISUtils.StopWatch
  # Starts the time counter
  StopWatch.Start()
  DoTest1()
  # Stops the time counter
  StopWatch.Stop()
  # Posts the passed time to the test log
  Log.Message("Test1 finished. Execution time: " + StopWatch.ToString())

VBScript

Sub Test

  Dim StopWatch
  Set StopWatch = HISUtils.StopWatch
  ' Starts the time counter
  StopWatch.Start
  DoTest1
  ' Stops the time counter
  StopWatch.Stop
  ' Posts the passed time to the test log
  Log.Message("Test1 finished. Execution time: " & StopWatch.ToString)

End Sub

DelphiScript

procedure Test();
var StopWatch;
begin
  StopWatch := HISUtils.StopWatch;
  // Starts the time counter
  StopWatch.Start;
  DoTest1;
  // Stops the time counter
  StopWatch.Stop;
  // Posts the passed time to the test log
  Log.Message('Test1 finished. Execution time: ' + StopWatch.ToString);

end;

C++Script, C#Script

function Test()
{
  var StopWatch;
  StopWatch = HISUtils["StopWatch"];
  // Starts the time counter
  StopWatch["Start"]();
  DoTest1();
  // Stops the time counter
  StopWatch["Stop"]();
  // Posts the passed time to the test log
  Log["Message"]("Test1 finished. Execution time: " + StopWatch["ToString"]());

}

See Also

Reset Method
Split Method
Start Method
ToString Method

Highlight search results