41
41
fi
42
42
43
43
# Directory containing this script
44
- readonly script_dir=" . "
44
+ readonly script_dir=` pwd `
45
45
46
46
# Change this if your checkout of github.com/protocolbuffers/protobuf is in a
47
47
# different location.
48
48
readonly 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" }
50
50
51
51
function usage() {
52
52
cat >&2 << EOF
123
123
124
124
echo " Running $language test harness alone..."
125
125
sleep 3
126
- DYLD_LIBRARY_PATH=" $script_dir /_generated " " $harness " " $partial_results "
126
+ DYLD_LIBRARY_PATH=` dirname $harness ` " $harness " " $partial_results "
127
127
sleep 3
128
128
129
129
cp " $harness " " ${harness} _stripped"
@@ -151,8 +151,10 @@ function profile_harness() {
151
151
perf_dir=" $3 "
152
152
153
153
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 "
156
158
}
157
159
158
160
# Inserts the partial visualization results from all the languages tested into
236
238
# Set up a hook to cleanup revision comparison checkouts when the script
237
239
# completes.
238
240
declare -a CLEANUP_WHEN_DONE
241
+ GIT_WORKTREE=" "
239
242
function cleanup_revision_checkouts() {
240
243
if [[ " ${# CLEANUP_WHEN_DONE[@]} " -ne 0 ]]; then
241
244
rm -rf " ${CLEANUP_WHEN_DONE[@]} "
242
245
fi
246
+ if [ " $GIT_WORKTREE " != " " ]; then
247
+ git worktree remove " $GIT_WORKTREE "
248
+ fi
243
249
}
244
250
trap cleanup_revision_checkouts EXIT HUP INT QUIT TERM
245
251
@@ -297,7 +303,9 @@ for comparison in "${comparisons[@]}"; do
297
303
echo " ==== Building/running C++ harness ===================="
298
304
echo
299
305
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 "
301
309
302
310
harness_cpp=" $script_dir /_generated/harness_cpp"
303
311
run_cpp_harness " $harness_cpp "
@@ -314,19 +322,20 @@ for comparison in "${comparisons[@]}"; do
314
322
315
323
# Check out the commit to a temporary directory and create its _generated
316
324
# 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"
328
337
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 "
330
339
else
331
340
echo
332
341
echo " ==== Found cached results for Swift ($comparison ) ===================="
@@ -341,10 +350,11 @@ echo "==== Building/running Swift harness (working tree) ===================="
341
350
echo
342
351
343
352
build_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 "
348
358
349
359
harness_swift=" $script_dir /_generated/harness_swift"
350
360
results_trace=" $script_dir /_results/$report_type (swift)"
359
369
360
370
insert_visualization_results " $partial_results " " $results_js "
361
371
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.
364
373
open -g " $script_dir /harness-visualization.html"
0 commit comments