4141fi
4242
4343# Directory containing this script
44- readonly script_dir=" . "
44+ readonly script_dir=` pwd `
4545
4646# Change this if your checkout of github.com/protocolbuffers/protobuf is in a
4747# different location.
4848readonly GOOGLE_PROTOBUF_CHECKOUT=${GOOGLE_PROTOBUF_CHECKOUT:- " $script_dir /../../protobuf" }
49- readonly PROTOC=${PROTOC:- " ${GOOGLE_PROTOBUF_CHECKOUT} /src/ protoc" }
49+ readonly PROTOC=${PROTOC:- " ${GOOGLE_PROTOBUF_CHECKOUT} /protoc" }
5050
5151function usage() {
5252 cat >&2 << EOF
123123
124124 echo " Running $language test harness alone..."
125125 sleep 3
126- DYLD_LIBRARY_PATH=" $script_dir /_generated " " $harness " " $partial_results "
126+ DYLD_LIBRARY_PATH=` dirname $harness ` " $harness " " $partial_results "
127127 sleep 3
128128
129129 cp " $harness " " ${harness} _stripped"
@@ -151,8 +151,10 @@ function profile_harness() {
151151 perf_dir=" $3 "
152152
153153 echo " Running $description test harness in Instruments..."
154- instruments -t " $script_dir /Protobuf" -D " $results_trace " \
155- " $harness " -e DYLD_LIBRARY_PATH " $perf_dir /_generated"
154+ mkdir -p " $results_trace "
155+ xctrace record --template ' Time Profiler' --output " $results_trace " \
156+ --env DYLD_LIBRARY_PATH=" $perf_dir /_generated" \
157+ --launch -- " $harness "
156158}
157159
158160# Inserts the partial visualization results from all the languages tested into
236238# Set up a hook to cleanup revision comparison checkouts when the script
237239# completes.
238240declare -a CLEANUP_WHEN_DONE
241+ GIT_WORKTREE=" "
239242function cleanup_revision_checkouts() {
240243 if [[ " ${# CLEANUP_WHEN_DONE[@]} " -ne 0 ]]; then
241244 rm -rf " ${CLEANUP_WHEN_DONE[@]} "
242245 fi
246+ if [ " $GIT_WORKTREE " != " " ]; then
247+ git worktree remove " $GIT_WORKTREE "
248+ fi
243249}
244250trap cleanup_revision_checkouts EXIT HUP INT QUIT TERM
245251
@@ -297,7 +303,9 @@ for comparison in "${comparisons[@]}"; do
297303 echo " ==== Building/running C++ harness ===================="
298304 echo
299305
300- ${PROTOC} --cpp_out=" $script_dir " " $gen_message_path "
306+ ${PROTOC} --cpp_out=" $script_dir /_generated" \
307+ --proto_path=` dirname $gen_message_path ` \
308+ " $gen_message_path "
301309
302310 harness_cpp=" $script_dir /_generated/harness_cpp"
303311 run_cpp_harness " $harness_cpp "
@@ -314,19 +322,20 @@ for comparison in "${comparisons[@]}"; do
314322
315323 # Check out the commit to a temporary directory and create its _generated
316324 # directory. (Results will still go in the working tree.)
317- tmp_checkout=" $( mktemp -d -t swiftprotoperf) "
318- CLEANUP_WHEN_DONE+=(" $tmp_checkout " )
319- git --work-tree=" $tmp_checkout " checkout " $comparison " -- .
320- mkdir " $tmp_checkout /Performance/_generated"
321-
322- build_swift_packages " $tmp_checkout " " ForRev"
323- ${PROTOC} --plugin=" $tmp_checkout /.build/release/protoc-gen-swiftForRev" \
324- --swiftForRev_out=FileNaming=DropPath:" $tmp_checkout /Performance/_generated" \
325- " $gen_message_path "
326-
327- harness_swift=" $tmp_checkout /Performance/_generated/harness_swift"
325+ GIT_WORKTREE=" $( mktemp -d ` pwd` /_generated/swiftprotoperf.XXXXXX) "
326+ CLEANUP_WHEN_DONE+=(" $GIT_WORKTREE " )
327+ git worktree add " $GIT_WORKTREE " " $comparison "
328+ mkdir " $GIT_WORKTREE /Performance/_generated"
329+
330+ build_swift_packages " $GIT_WORKTREE " " ForRev"
331+ ${PROTOC} --plugin=" $GIT_WORKTREE /.build/release/protoc-gen-swiftForRev" \
332+ --swiftForRev_out=FileNaming=DropPath:" $GIT_WORKTREE /Performance/_generated" \
333+ --proto_path=` dirname $gen_message_path ` \
334+ " $gen_message_path "
335+
336+ harness_swift=" $GIT_WORKTREE /Performance/_generated/harness_swift"
328337 results_trace=" $script_dir /_results/$report_type (swift)"
329- run_swift_harness " $tmp_checkout " " $comparison " " $commit_results "
338+ run_swift_harness " $GIT_WORKTREE " " $comparison " " $commit_results "
330339 else
331340 echo
332341 echo " ==== Found cached results for Swift ($comparison ) ===================="
@@ -341,10 +350,11 @@ echo "==== Building/running Swift harness (working tree) ===================="
341350echo
342351
343352build_swift_packages " $script_dir /.." " ForWorkTree"
344- ${PROTOC} --plugin=" $script_dir /../.build/release/protoc-gen-swiftForWorkTree" \
345- --swiftForWorkTree_out=FileNaming=DropPath:" $script_dir /_generated" \
346- --cpp_out=" $script_dir " \
347- " $gen_message_path "
353+
354+ ${PROTOC} --plugin=" $script_dir /../.build/release/protoc-gen-swift" \
355+ --swift_out=FileNaming=DropPath:` dirname $gen_message_path ` \
356+ --proto_path=` dirname $gen_message_path ` \
357+ " $gen_message_path "
348358
349359harness_swift=" $script_dir /_generated/harness_swift"
350360results_trace=" $script_dir /_results/$report_type (swift)"
359369
360370insert_visualization_results " $partial_results " " $results_js "
361371
362- # Open the Instruments trace and HTML report at the end.
363- open -g " $display_results_trace .trace"
372+ # Open the HTML report at the end.
364373open -g " $script_dir /harness-visualization.html"
0 commit comments