#!/bin/sh -efu

get_ip_address_user_time()
{
	# user 0m0.099s

	local user_time system_time
	# shellcheck disable=SC2034  # system_time is only consumed
	read -r user_time system_time ||:

	user_time="${user_time%.*}"

	echo "$user_time"
}

ip_address_performance_test1() { # UnitTest
	local result seconds

	result="$("$TEST_SHELL" -efu ./ip-address-data/ipv4-ipv6-ptonx.sh | get_ip_address_user_time)"
	seconds=$(( (${result%m*} * 60) + ${result#*m} ))

	case "${TEST_SHELL##*/}" in
		bash*|*ksh)
			assertTrue "ipv4_ptonx and ipv6_ptonx are too slow: $result" \
				"test $seconds -lt 12"
			;;
		dash*|*ash)
			assertTrue "ipv4_ptonx and ipv6_ptonx are too slow: $result" \
				"test $seconds -lt 4"
			;;
		*)
			assertTrue "ipv4_ptonx and ipv6_ptonx are too slow: $result" \
				"test $seconds -lt 12"
			;;
	esac
}
