Reset Method

Applies to TestComplete 15.20, last modified on January 19, 2022

Description

The StopWatch.Reset method zeros the StopWatch counter.

Declaration

StopWatchObj.Reset()

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

Applies To

The method is applied to the following object:

Result Value

None.

Example

The following code snippet starts several tests and measures how much time has been spent executing each of them.

JavaScript, JScript

function Test()

{
  var Watch;
  // Obtains the StopWatch object
  Watch = HISUtils.StopWatch;

  // Starts the time counter
  Watch.Start();
  DoTest1();
  // Stops the time counter
  Watch.Stop();
  Log.Message("Test1 finished. Execution time: " + Watch.ToString());

  // Resets the time counter
  Watch.Reset();
  // Starts the time counter
  Watch.Start();
  DoTest2();
  // Stops the time counter
  Watch.Stop();
  Log.Message("Test2 finished. Execution time: " + Watch.ToString());

}

Python

def Test():

  # Obtains the StopWatch object
  Watch = HISUtils.StopWatch

  # Starts the time counter
  Watch.Start()
  DoTest1()
  # Stops the time counter
  Watch.Stop()
  Log.Message("Test1 finished. Execution time: " + Watch.ToString())

  # Resets the time counter
  Watch.Reset()
  # Starts the time counter
  Watch.Start()
  DoTest2()
  # Stops the time counter
  Watch.Stop()
  Log.Message("Test2 finished. Execution time: " + Watch.ToString())

VBScript

Sub Test

  Dim Watch
  ' Obtains the StopWatch object
  Set Watch = HISUtils.StopWatch

  ' Starts the time counter
  Watch.Start
  DoTest1
  ' Stops the time counter
  Watch.Stop
  Log.Message("Test1 finished. Execution time: " & Watch.ToString)

  ' Resets the time counter
  Watch.Reset
  ' Starts the time counter
  Watch.Start
  DoTest2
  ' Stops the time counter
  Watch.Stop
  Log.Message("Test2 finished. Execution time: " & Watch.ToString)

End Sub

DelphiScript

procedure Test();
var Watch;
begin
  // Obtains the StopWatch object
  Watch := HISUtils.StopWatch;

  // Starts the time counter
  Watch.Start;
  DoTest1;
  // Stops the time counter
  Watch.Stop;
  Log.Message('Test1 finished. Execution time: ' + Watch.ToString);

  // Resets the time counter
  Watch.Reset;
  // Starts the time counter
  Watch.Start;
  DoTest2;
  // Stops the time counter
  Watch.Stop;
  Log.Message('Test2 finished. Execution time: ' + Watch.ToString);

end;

C++Script, C#Script

function Test()

{
  var Watch;
  // Obtains the StopWatch object
  Watch = HISUtils["StopWatch"];

  // Starts the time counter
  Watch["Start"]();
  DoTest1();
  // Stops the time counter
  Watch["Stop"]();
  Log["Message"]("Test1 finished. Execution time: " + Watch["ToString"]());

  // Resets the time counter
  Watch["Reset"]();
  // Starts the time counter
  Watch["Start"]();
  DoTest2();
  // Stops the time counter
  Watch["Stop"]();
  Log["Message"]("Test2 finished. Execution time: " + Watch["ToString"]());

}

See Also

Split Method
Start Method
Stop Method
ToString Method

Highlight search results