Skip to content

Instantly share code, notes, and snippets.

@daxmc99
Last active August 26, 2021 21:57
Show Gist options
  • Save daxmc99/890260959a4067e5c1dced7e2a63ce21 to your computer and use it in GitHub Desktop.
Save daxmc99/890260959a4067e5c1dced7e2a63ce21 to your computer and use it in GitHub Desktop.
Create a number of perforce text files and add them each as a changelist
#!/usr/bin/env bash
set -Eeu
set -x
# You need to use a session ticket (https://about.sourcegraph.com/handbook/support/p4-enablement#generate-a-session-ticket)
# in order to avoid password prompts
# TO edit this file, you must run `p4 edit create-revision.sh` first
suffix="baz"
client="dax3"
file_size="5000000" # 1,000,000 ~ 1MB
big_file_size_bytes="1000000000" # 1 GB
start=$(date +%s)
for num in {1..1000}; do
echo "writing file ${num}"
base64 /dev/urandom | head -c ${file_size} > ./test/"${num}_${suffix}".txt
if [ $(( num % 10 )) -eq 0 ]; then
base64 /dev/urandom | head -c ${big_file_size_bytes} > ./test/"${num}_big_${suffix}".txt
fi
p4 -c ${client} add test/"${num}_${suffix}".txt
p4 -c ${client} submit -d "test-$num"
done
end=$(date +%s)
runtime=$((end-start))
echo "Finished in ${runtime}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment