NetBurner 3.5.6
PDF Version
Stopwatch Timer

Stopwatch Example Application

Overview

This application demonstrates the usage of a StopWatch timer object for measuring execution time of code segments. The StopWatch class provides precise timing capabilities for performance measurement and profiling.

Application Description

The Stopwatch Example application is a NetBurner RTOS-based program that showcases how to use the StopWatch class to measure the execution time of a simple counting loop.

Key Features

  • Demonstrates StopWatch object creation and usage
  • Measures execution time of a 10,000 iteration loop
  • Displays timing results with high precision
  • Shows timer resolution capabilities
  • Includes system diagnostics and network initialization

Code Structure

Main Components

  • StopWatch Object: Core timing functionality
  • Performance Test: Simple counting loop for demonstration
  • System Initialization: Network and diagnostic setup
  • Continuous Operation: Maintains application state

Execution Flow

  1. Initialize system and enable diagnostics
  2. Wait for active network connection
  3. Create StopWatch instance
  4. Start timing measurement
  5. Execute 10,000 iteration counting loop
  6. Stop timing measurement
  7. Display elapsed time and timer resolution
  8. Enter continuous operation mode

Usage

The application automatically runs the timing demonstration upon startup. The output includes:

  • Elapsed time in timer ticks
  • Elapsed time converted to seconds (scientific notation)
  • Timer resolution in seconds

Sample Output

Starting stopwatch on for loop of 10000 counts...complete
Elapsed time: [ticks], [seconds] seconds
Resolution: [resolution] seconds
time_t time(time_t *pt)
Gets the current system GMT time.

StopWatch Class Interface

Based on the documentation, the StopWatch class provides:

  • Start(): Begin timing measurement
  • Stop(): End timing measurement
  • GetTime(): Retrieve elapsed time in timer ticks
  • Convert(): Convert timer ticks to seconds
  • CountResolution(): Get timer resolution

System Requirements

  • NetBurner RTOS environment
  • Network connectivity (application waits for active network)
  • Compatible NetBurner hardware platform

Build Dependencies

Notes

  • System diagnostics are enabled for development/debugging
  • Application enters infinite loop after demonstration
  • Uses OSTimeDly(TICKS_PER_SECOND) for timing delays
  • Designed for embedded NetBurner platforms