Skip to content

Instantly share code, notes, and snippets.

@brandonpollack23
Created May 16, 2025 02:27
Show Gist options
  • Select an option

  • Save brandonpollack23/eadfdf5f2b983f5441cb46b2e147519e to your computer and use it in GitHub Desktop.

Select an option

Save brandonpollack23/eadfdf5f2b983f5441cb46b2e147519e to your computer and use it in GitHub Desktop.
Bisect for perf tests in pulumi
make install
pushd sdk/nodejs
make install_plugin
popd
pushd ../../examples/examples/misc/test
# Capture the output of the test command
test_output_raw=$(esc run pulumi/providers/all -- go test -json . --timeout 4h -v -count=1 -short -parallel 40 --tags=all --run=TestAccAwsTsS3Folder | gotestfmt)
echo "$test_output_raw"
test_output=$(echo "$test_output_raw" | grep -e 'TestAccAwsTsS3Folder' | head -n 1)
echo "test output: $test_output"
popd
# Extract the time string inside parentheses, e.g., 1m27.51s or 27.51s
# Use sed for macOS compatibility and handle both formats
time_str=$(echo "$test_output" | sed -n 's/.*(\([^)]*\)).*/\1/p' | head -n 1)
echo "time string: $time_str"
# Default to 0 if not found
if [ -z "$time_str" ]; then
echo "No time found in test output."
exit 1
fi
# Parse minutes and seconds
if [[ $time_str == *m* ]]; then
min=$(echo "$time_str" | grep -oE '^[0-9]+')
sec=$(echo "$time_str" | grep -oE '[0-9]+\.[0-9]+')
else
min=0
sec=$(echo "$time_str" | grep -oE '[0-9]+\.[0-9]+')
fi
# Calculate total seconds
if command -v bc >/dev/null 2>&1; then
total=$(echo "$min * 60 + $sec" | bc)
else
total=$(awk -v m="$min" -v s="$sec" 'BEGIN {print m*60+s}')
fi
limit=120
result=$(echo "$total < $limit" | bc)
if [ "$result" -eq 1 ]; then
echo "Test ran fast enough in $total seconds"
exit 0
else
echo "Test ran too slow in $total seconds"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment