measure Method

New for Internet Explorer 9

[This documentation is preliminary and is subject to change.]

Defines a performance measure between two performance marks.

Syntax

MSPerformance.measure(sMeasureName, sStartMarkName, sEndMarkName)

Parameters

sMeasureName Required. The desired name for the performance measure.
sStartMarkName Required. Name of the starting performance mark.
sEndMarkName Required. Name of the ending performance mark.

Return Value

No return value.

Remarks

The measure method defines a performance measure; use the getMeasure and getMeasures methods to get the elapsed time for the performance measure.

Example

The following example shows how to use to the measure method to define a custom performance measure.

<!DOCTYPE html>
<head>
  <meta http-equiv="x-ua-compatible" content="ie=9">
  <script type="text/javascript">

    function doLoop() {
      var maxIter = 500000;
      var fib = 0;
      var fibn_1 = 0;
      var fibn_2 = 1;

      for (var i = 0; i < maxIter; i++) {
        fib = (fib == 0) ? 0 : fib;
        fib = fibn_1 + fibn_2;
        fibn_2 = fibn_1;
        fibn_1 = fib;
      }
    }
  </script>
</head>
<body>

  <script type="text/javascript">
  try
  {
     var oPerformance = window.msPerformance;
     oPerformance.mark("MyLoopStart");
     doLoop();
     oPerformance.mark("MyLoopEnd");
     oPerformance.measure("MyLoopTime", "MyLoopStart", "MyLoopEnd");
     iMyLoopMS = oPerformance.getMeasure("MyLoopTime")
     alert( "The loop took " + iMyLoopMS.toString() + " ms to execute." );
    } catch( oErr ) {
        var str = "Error " + oErr.code + ": " + oErr.message;
        alert( str );
    };
  </script>

</body>
</html>

Standards Information

There is no public standard that applies to this method.

Applies To

MSPerformance

See Also

getMeasure, getMeasures, markAndMeasure