#!/usr/bin/env python

import time
import wallclock as w

# Wallclock is initially disabled, this push is a no-op.
w.push('ignored')

# Wallclock is now enabled; stack: ['start']
w.push('start', enable=True)
time.sleep(0.5)

# Stack: ['start', 'inner a']
w.push('inner a')
time.sleep(0.3)
# Stack: ['start'], timing for 'inner a' recorded as a child of 'start'
w.pop('inner a')

# Stack: ['start', 'inner b']
w.push('inner b')
time.sleep(0.2)
# Stack: ['start'], timing for 'inner b' recorded as second child of 'start'
w.pop('inner b')

# Stack: [], wallclock disabled and the timing for 'start' and children
# passed to wallclock.output, producing:
#
# [1.004 sec] start
#   [0.301 sec] inner a
#   [0.201 sec] inner b
#
# on stderr.
w.pop('start')

# Matches initial ignored pop, also a no-op but it pays to be tidy.
w.pop('ignored')
