Skip to content

Commit 3baa193

Browse files
authored
Merge branch 'master' into cb-try-raw-pointer
2 parents defcb54 + edd69ca commit 3baa193

24 files changed

+11977
-11586
lines changed

Performance/generators/cpp.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ function print_cpp_set_field() {
2121
type=$2
2222

2323
case "$type" in
24+
repeated\ message)
25+
echo " for (auto i = 0; i < repeated_count; i++) {"
26+
echo " message.add_field$num()->set_optional_int32($((200+num)));"
27+
echo " }"
28+
;;
2429
repeated\ string)
2530
echo " for (auto i = 0; i < repeated_count; i++) {"
2631
echo " message.add_field$num(\"$((200+num))\");"
@@ -51,6 +56,9 @@ function print_cpp_set_field() {
5156
echo " message.add_field$num($((200+num)));"
5257
echo " }"
5358
;;
59+
message)
60+
echo " message.mutable_field$num()->set_optional_int32($((200+num)));"
61+
;;
5462
string)
5563
echo " message.set_field$num(\"$((200+num))\");"
5664
;;

Performance/generators/proto.sh

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,31 @@ function print_proto_field() {
3737
function generate_homogeneous_test_proto() {
3838
cat >"$gen_message_path" <<EOF
3939
syntax = "proto$proto_syntax";
40+
EOF
41+
42+
case "$field_type" in
43+
*message)
44+
case "$field_type" in
45+
repeated\ message)
46+
out_field_type="repeated SubMessage"
47+
;;
48+
message)
49+
out_field_type="SubMessage"
50+
;;
51+
*)
52+
echo "XXX Invalid field type ``$field_type''"
53+
;;
54+
esac
55+
echo "message SubMessage {" >>"$gen_message_path"
56+
echo " int32 optional_int32 = 1;" >>"$gen_message_path"
57+
echo "}" >>"$gen_message_path"
58+
;;
59+
*)
60+
out_field_type="$field_type"
61+
;;
62+
esac
4063

64+
cat >>"$gen_message_path" <<EOF
4165
message PerfMessage {
4266
enum PerfEnum {
4367
ZERO = 0;
@@ -49,7 +73,7 @@ message PerfMessage {
4973
EOF
5074

5175
for field_number in $(seq 1 "$field_count"); do
52-
print_proto_field "$field_number" "$field_type" >>"$gen_message_path"
76+
print_proto_field "$field_number" "$out_field_type" >>"$gen_message_path"
5377
done
5478

5579
cat >>"$gen_message_path" <<EOF

Performance/generators/swift.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ function print_swift_set_field() {
2121
type=$2
2222

2323
case "$type" in
24+
repeated\ message)
25+
echo " for _ in 0..<repeatedCount {"
26+
echo " message.field$num.append(SubMessage.with { \$0.optionalInt32 = $((200+num)) })"
27+
echo " }"
28+
;;
2429
repeated\ bytes)
2530
echo " for _ in 0..<repeatedCount {"
2631
echo " message.field$num.append(Data(repeating:$((num)), count: 20))"
@@ -56,6 +61,9 @@ function print_swift_set_field() {
5661
echo " message.field$num.append($((200+num)))"
5762
echo " }"
5863
;;
64+
message)
65+
echo " message.field$num = SubMessage.with { \$0.optionalInt32 = $((200+num)) }"
66+
;;
5967
bytes)
6068
echo " message.field$num = Data(repeating:$((num)), count: 20)"
6169
;;
@@ -98,6 +106,10 @@ extension Harness {
98106
populateFields(of: &message)
99107
}
100108
109+
message = measureSubtask("Populate fields with with") {
110+
return populateFieldsWithWith()
111+
}
112+
101113
// Exercise binary serialization.
102114
let data = try measureSubtask("Encode binary") {
103115
return try message.serializedData()
@@ -140,6 +152,20 @@ EOF
140152

141153
cat >> "$gen_harness_path" <<EOF
142154
}
155+
156+
private func populateFieldsWithWith() -> PerfMessage {
157+
return PerfMessage.with { message in
158+
EOF
159+
160+
if [[ "$proto_type" == "homogeneous" ]]; then
161+
generate_swift_homogenerous_populate_fields_body
162+
else
163+
generate_swift_heterogenerous_populate_fields_body
164+
fi
165+
166+
cat >> "$gen_harness_path" <<EOF
167+
}
168+
}
143169
}
144170
EOF
145171
}

Performance/js/harness-visualization.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// on the plot axis.
44
var benchmarks = [
55
'New message', 'Populate fields',
6+
'Populate fields with with',
67
'Encode binary', 'Decode binary',
78
'Encode JSON', 'Decode JSON',
89
'Encode text', 'Decode text',

0 commit comments

Comments
 (0)