Skip to content

Commit

Permalink
fix: remove decimals on original time before looking for mins
Browse files Browse the repository at this point in the history
  • Loading branch information
Chemaclass committed Oct 12, 2024
1 parent 5e201d1 commit d4d7c57
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions src/console_results.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,20 @@ function console_results::print_execution_time() {
return
fi

local time=$(clock::total_runtime_in_milliseconds)
local time=$(printf "%.0f" "$(clock::total_runtime_in_milliseconds)")

# Convert time to seconds if greater than or equal to 1000 ms
if [[ "$time" -ge 1000 ]]; then
local time_in_seconds=$(echo "scale=2; $time / 1000" | bc)
printf "${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" \
"Time taken: $time_in_seconds s"
else
if [[ "$time" -lt 1000 ]]; then
printf "${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" \
"Time taken: $time ms"
return
fi

local time_in_seconds=$(( time / 1000 ))
local remainder_ms=$(( time % 1000 ))
local formatted_seconds=$(printf "%.2f" "$time_in_seconds.$remainder_ms")

printf "${_COLOR_BOLD}%s${_COLOR_DEFAULT}\n" \
"Time taken: $formatted_seconds s"
}

function console_results::print_successful_test() {
Expand Down

0 comments on commit d4d7c57

Please sign in to comment.