Split Method

Applies to TestComplete 15.0, last modified on November 17, 2021

Description

The StopWatch.Split method returns the number of milliseconds passed since the start of the StopWatch. To convert the number of passed milliseconds into a readable time format, use the StopWatch.ToString routine.

Declaration

StopWatchObj.Split()

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.

Remarks

Use the Split method for running timers only. To get the number of passed milliseconds upon stopping the timer, use the StopWatch.Stop method.

Example

The following code snippet runs several tests and measures how much time has passed since the start of the time counter till the end of each test execution.

JavaScript, JScript

function Test()
{

  var Watch;

  // Obtains the StopWatch object
  Watch = HISUtils.StopWatch;
  // Starts the time counter
  Watch.Start();
  DoTest1();
  // Returns the time passed since the start of the time counter
  Watch.Split();
  Log.Message("Test1 finished. Execution time: " + Watch.ToString());

  DoTest2();
  // Returns the time passed since the start of the time counter
  Watch.Split();
  Log.Message("Test2 finished. Execution time: " + Watch.ToString());

  …

  // Stops the time counter
  Watch.Stop();
  Log.Message("Testing finished. Execution time: " + Watch.ToString());

}

Python

def Test():

  # Obtains the StopWatch object
  Watch = HISUtils.StopWatch
  # Starts the time counter
  Watch.Start()
  DoTest1()
  # Returns the time passed since the start of the time counter
  Watch.Split()
  Log.Message("Test1 finished. Execution time: " + Watch.ToString())

  DoTest2()
  # Returns the time passed since the start of the time counter
  Watch.Split()
  Log.Message("Test2 finished. Execution time: " + Watch.ToString())

  # ...

  # Stops the time counter
  Watch.Stop()
  Log.Message("Testing 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
  ' Returns the time passed since the start of the time counter
  Watch.Split
  Log.Message("Test1 finished. Execution time: " & Watch.ToString)

  DoTest2
  ' Returns the time passed since the start of the time counter
  Watch.Split
  Log.Message("Test2 finished. Execution time: " & Watch.ToString)

  …

  ' Stops the time counter
  Watch.Stop
  Log.Message("Testing 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();
  // Returns the time passed since the start of the time counter
  Watch.Split();
  Log.Message('Test1 finished. Execution time: ' + Watch.ToString());

  DoTest2();
  // Returns the time passed since the start of the time counter
  Watch.Split();
  Log.Message('Test2 finished. Execution time: ' + Watch.ToString());

  …

  // Stops the time counter
  Watch.Stop();
  Log.Message('Testing 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();
  // Returns the time passed since the start of the time counter
  Watch["Split"]();
  Log["Message"]("Test1 finished. Execution time: " + Watch["ToString"]());

  DoTest2();
  // Returns the time passed since the start of the time counter
  Watch["Split"]();
  Log["Message"]("Test2 finished. Execution time: " + Watch["ToString"]());

  …

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

}

See Also

Reset Method
Start Method
Stop Method
ToString Method

Highlight search results