puts "========"
puts "OCC25487"
puts "========"
puts ""
##########################################
# Extrema_GenExtPS needs to be optimized
##########################################

pload DATAEXCHANGEKERNEL

# Restore testing shape and get timing characteristics for operation stepread
dchrono perf_h reset
dchrono perf_h start
stepread [locate_data_file OCC25487_LP1.stp] a *
dchrono perf_h stop

# Get elapsed time for operation stepread
set chrono_info [dchrono perf_h show]
regexp {CPU user time: ([-0-9.+eE]+) seconds} $chrono_info full CPU_time
puts "Elapsed time is: $CPU_time"

# Check current OS
set currentOS $tcl_platform(os)

# Check prformance on Windows
if {[string compare $currentOS "Windows NT"] == 0} {
  if {[regexp {Debug mode} [dversion]]} {
    # DEBUG mode
    # initial CPU_time for WINDOWS in DEBUG mode is 410 ((186+19)*2) sec
    puts "Checking WINDOWS performance in debug mode..."
    if {$CPU_time > 410.} {
      puts "ERROR: OCC25487 is reproduced."
      puts "       Low performance: $CPU_time (but should be less than 410 sec)"
    } else {
      puts "Done!"
    }
  } else {
    # OPTIMIZE mode
    # initial CPU_time for WINDOWS in OPTIMIZE mode is 205 (186+19) sec
    puts "Checking WINDOWS performance in optimize mode..."
    if {$CPU_time > 205.} {
      puts "ERROR: OCC25487 is reproduced."
      puts "       Low performance: $CPU_time (but should be less than 205 sec)"
    } else {
      puts "Done!"
    }
  }
}

# Check performance on Linux
if {[string compare $currentOS "Linux"] == 0} {
  if {[regexp {Debug mode} [dversion]]} {
    # DEBUG mode
    # initial CPU_time for LINUX in DEBUG mode is 900 sec
    puts "Checking LINUX performance in debug mode..."
    if {$CPU_time > 900.} {
      puts "ERROR: OCC25487 is reproduced."
      puts "       Low performance: $CPU_time (but should be less than 900 sec)"
    } else {
      puts "Done!"
    }
  } else {
    # OPTIMIZE mode
    # initial CPU_time for LINUX in OPTIMIZE mode is 190 (173+17) sec
    puts "Checking LINUX performance in optimize mode..."
    if {$CPU_time > 190.} {
      puts "ERROR: OCC25487 is reproduced."
      puts "       Low performance: $CPU_time (but should be less than 190 sec)"
    } else {
      puts "Done!"
    }
  }
}
