Skip to content

Commit

Permalink
fix: time in macOS and freeBSD
Browse files Browse the repository at this point in the history
- use of gdate (coreutils) for macOS
- switch to `ns` in place of `ms` for freeBSD
  • Loading branch information
meo-pill committed Jan 7, 2025
1 parent 69a087d commit 5b194a2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install coreutils
run: brew install coreutils

- name: Run testing script on macOS
run: ./testing.sh

Expand Down
36 changes: 27 additions & 9 deletions testing.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,21 @@ function prepare() {
cp -rf $test_data_src $test_pool_data_path
}

# return time to the milisecond
function get_time() {

case "$OSTYPE" in
darwin*)
date=$(gdate +%s%N)
;;
*)
date=$(date +%s%N)
;;
esac

echo "$date"
}

function assertions() {
# check error log is empty
if grep -q '[^[:space:]]' $log_error_file; then
Expand Down Expand Up @@ -139,30 +154,33 @@ color_echo "$Green" "Files created!"

echo "Running rebalancing on small files..."
# measure time taken
start_time=$(date +%s%3N)
start_time=$(get_time)
./zfs-inplace-rebalancing.sh $test_pool_data_size_path/small >> $log_std_file 2>> $log_error_file
end_time=$(date +%s%3N)
print_time_taken $((end_time - start_time))
end_time=$(get_time)
time_taken=$(( (end_time - start_time) / 1000000 ))
print_time_taken $time_taken
assertions
color_echo "$Green" "Tests passed!"

echo "Running rebalancing on big files..."
rm -f rebalance_db.txt
# measure time taken
start_time=$(date +%s%3N)
start_time=$(get_time)
./zfs-inplace-rebalancing.sh $test_pool_data_size_path/big >> $log_std_file 2>> $log_error_file
end_time=$(date +%s%3N)
print_time_taken $((end_time - start_time))
end_time=$(get_time)
time_taken=$(( (end_time - start_time) / 1000000 ))
print_time_taken $time_taken
assertions
color_echo "$Green" "Tests passed!"

echo "Running rebalancing on all files..."
rm -f rebalance_db.txt
# measure time taken
start_time=$(date +%s%3N)
start_time=$(get_time)
./zfs-inplace-rebalancing.sh $test_pool_data_size_path >> $log_std_file 2>> $log_error_file
end_time=$(date +%s%3N)
print_time_taken $((end_time - start_time))
end_time=$(get_time)
time_taken=$(( (end_time - start_time) / 1000000 ))
print_time_taken $time_taken
assertions
color_echo "$Green" "Tests passed!"

Expand Down

0 comments on commit 5b194a2

Please sign in to comment.