Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: google/protobuf.dart
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 100969207d77e2b06e54b9de761b7f3ac0205ae2
Choose a base ref
..
head repository: google/protobuf.dart
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2024979c53dc2bf122e8bc48a19942c2ca922ff8
Choose a head ref
Showing with 2,527 additions and 1,988 deletions.
  1. +29 −29 .github/workflows/dart.yml
  2. +10 −0 .gitignore
  3. +6 −12 analysis_options.yaml
  4. +2 −0 api_benchmark/analysis_options.yaml
  5. +12 −12 api_benchmark/lib/benchmark.dart
  6. +8 −8 api_benchmark/lib/benchmarks/get_strings.dart
  7. +8 −8 api_benchmark/lib/benchmarks/has_strings.dart
  8. +3 −3 api_benchmark/lib/benchmarks/index.dart
  9. +7 −7 api_benchmark/lib/benchmarks/int32_json.dart
  10. +7 −7 api_benchmark/lib/benchmarks/int64_json.dart
  11. +6 −6 api_benchmark/lib/benchmarks/repeated_int32_json.dart
  12. +6 −6 api_benchmark/lib/benchmarks/repeated_int64_json.dart
  13. +8 −8 api_benchmark/lib/benchmarks/repeated_string_json.dart
  14. +8 −8 api_benchmark/lib/benchmarks/set_strings.dart
  15. +9 −9 api_benchmark/lib/benchmarks/string_json.dart
  16. +25 −25 api_benchmark/lib/dashboard.dart
  17. +7 −6 api_benchmark/lib/dashboard_model.dart
  18. +13 −13 api_benchmark/lib/dashboard_view.dart
  19. +16 −16 api_benchmark/lib/report.dart
  20. +10 −10 api_benchmark/lib/suite.dart
  21. +1 −1 api_benchmark/lib/suites/json.dart
  22. +1 −1 api_benchmark/lib/suites/props.dart
  23. +16 −16 api_benchmark/lib/vm.dart
  24. +5 −4 api_benchmark/pubspec.yaml
  25. +2 −2 api_benchmark/tool/builder.dart
  26. +5 −6 benchmarks/bin/deep_copy.dart
  27. +5 −6 benchmarks/bin/from_binary.dart
  28. +5 −6 benchmarks/bin/from_json_string.dart
  29. +5 −6 benchmarks/bin/from_proto3_json_object.dart
  30. +5 −6 benchmarks/bin/from_proto3_json_string.dart
  31. +5 −6 benchmarks/bin/hash_code.dart
  32. +2 −2 benchmarks/bin/query_decode_binary.dart
  33. +3 −4 benchmarks/bin/query_decode_json.dart
  34. +2 −4 benchmarks/bin/query_encode_binary.dart
  35. +2 −4 benchmarks/bin/query_encode_json.dart
  36. +3 −4 benchmarks/bin/query_set_nested_value.dart
  37. +5 −6 benchmarks/bin/to_binary.dart
  38. +5 −6 benchmarks/bin/to_json_string.dart
  39. +5 −6 benchmarks/bin/to_proto3_json_object.dart
  40. +5 −6 benchmarks/bin/to_proto3_json_string.dart
  41. +1 −1 benchmarks/lib/benchmark_base.dart
  42. +2 −2 benchmarks/pubspec.yaml
  43. +1 −1 benchmarks/tool/compile_benchmarks.dart
  44. +11 −3 protobuf/CHANGELOG.md
  45. +8 −6 protobuf/lib/protobuf.dart
  46. +1 −1 protobuf/lib/src/protobuf/annotations.dart
  47. +14 −13 protobuf/lib/src/protobuf/builder_info.dart
  48. +22 −22 protobuf/lib/src/protobuf/coded_buffer.dart
  49. +40 −12 protobuf/lib/src/protobuf/coded_buffer_reader.dart
  50. +13 −12 protobuf/lib/src/protobuf/coded_buffer_writer.dart
  51. +1 −1 protobuf/lib/src/protobuf/consts.dart
  52. +1 −1 protobuf/lib/src/protobuf/event_plugin.dart
  53. +1 −1 protobuf/lib/src/protobuf/exceptions.dart
  54. +2 −2 protobuf/lib/src/protobuf/extension.dart
  55. +11 −11 protobuf/lib/src/protobuf/extension_field_set.dart
  56. +48 −23 protobuf/lib/src/protobuf/extension_registry.dart
  57. +1 −1 protobuf/lib/src/protobuf/field_error.dart
  58. +6 −6 protobuf/lib/src/protobuf/field_info.dart
  59. +58 −58 protobuf/lib/src/protobuf/field_set.dart
  60. +1 −1 protobuf/lib/src/protobuf/field_type.dart
  61. +6 −6 protobuf/lib/src/protobuf/generated_message.dart
  62. +1 −1 protobuf/lib/src/protobuf/generated_service.dart
  63. +15 −15 protobuf/lib/src/protobuf/json.dart
  64. +1 −1 protobuf/lib/src/protobuf/json_parsing_context.dart
  65. +146 −0 protobuf/lib/src/protobuf/message_set.dart
  66. +6 −6 protobuf/lib/src/protobuf/mixins/event_mixin.dart
  67. +3 −3 protobuf/lib/src/protobuf/mixins/map_mixin.dart
  68. +62 −62 protobuf/lib/src/protobuf/mixins/well_known.dart
  69. +2 −2 protobuf/lib/src/protobuf/pb_list.dart
  70. +6 −6 protobuf/lib/src/protobuf/pb_map.dart
  71. +18 −17 protobuf/lib/src/protobuf/proto3_json.dart
  72. +3 −12 protobuf/lib/src/protobuf/protobuf_enum.dart
  73. +1 −1 protobuf/lib/src/protobuf/rpc_client.dart
  74. +16 −16 protobuf/lib/src/protobuf/unknown_field_set.dart
  75. +3 −3 protobuf/lib/src/protobuf/unpack.dart
  76. +1 −1 protobuf/lib/src/protobuf/utils.dart
  77. +1 −1 protobuf/lib/src/protobuf/wire_format.dart
  78. +3 −3 protobuf/pubspec.yaml
  79. +9 −9 protobuf/test/codec_test.dart
  80. +6 −8 protobuf/test/coded_buffer_reader_test.dart
  81. +29 −35 protobuf/test/event_test.dart
  82. +9 −9 protobuf/test/json_test.dart
  83. +1 −0 protobuf/test/json_vm_test.dart
  84. +14 −13 protobuf/test/list_test.dart
  85. +14 −13 protobuf/test/map_mixin_test.dart
  86. +10 −14 protobuf/test/message_test.dart
  87. +2 −2 protobuf/test/mock_util.dart
  88. +23 −29 protobuf/test/readonly_message_test.dart
  89. +22 −6 protoc_plugin/CHANGELOG.md
  90. +4 −9 protoc_plugin/Makefile
  91. +6 −0 protoc_plugin/analysis_options.yaml
  92. +1 −1 protoc_plugin/bin/protoc_plugin_bazel.dart
  93. +4 −4 protoc_plugin/legacy_tests/generated_message_test.dart
  94. +14 −14 protoc_plugin/lib/bazel.dart
  95. +2 −2 protoc_plugin/lib/const_generator.dart
  96. +7 −7 protoc_plugin/lib/indenting_writer.dart
  97. +4 −2 protoc_plugin/lib/mixins.dart
  98. +31 −31 protoc_plugin/lib/names.dart
  99. +1 −1 protoc_plugin/lib/src/base_type.dart
  100. +9 −9 protoc_plugin/lib/src/client_generator.dart
  101. +8 −8 protoc_plugin/lib/src/code_generator.dart
  102. +8 −8 protoc_plugin/lib/src/enum_generator.dart
  103. +10 −10 protoc_plugin/lib/src/extension_generator.dart
  104. +89 −87 protoc_plugin/lib/src/file_generator.dart
  105. +19 −19 protoc_plugin/lib/src/generated/dart_options.pb.dart
  106. +245 −245 protoc_plugin/lib/src/generated/descriptor.pb.dart
  107. +1 −2 protoc_plugin/lib/src/generated/descriptor.pbenum.dart
  108. +37 −37 protoc_plugin/lib/src/generated/plugin.pb.dart
  109. +1 −2 protoc_plugin/lib/src/generated/plugin.pbenum.dart
  110. +4 −4 protoc_plugin/lib/src/grpc_generator.dart
  111. +8 −8 protoc_plugin/lib/src/linker.dart
  112. +62 −54 protoc_plugin/lib/src/message_generator.dart
  113. +7 −7 protoc_plugin/lib/src/options.dart
  114. +4 −4 protoc_plugin/lib/src/output_config.dart
  115. +11 −11 protoc_plugin/lib/src/protobuf_field.dart
  116. +21 −21 protoc_plugin/lib/src/service_generator.dart
  117. +4 −4 protoc_plugin/pubspec.yaml
  118. +14 −14 protoc_plugin/test/any_test.dart
  119. +21 −21 protoc_plugin/test/bazel_test.dart
  120. +7 −7 protoc_plugin/test/client_generator_test.dart
  121. +8 −8 protoc_plugin/test/coded_buffer_test.dart
  122. +1 −1 protoc_plugin/test/const_generator_test.dart
  123. +4 −4 protoc_plugin/test/enum_generator_test.dart
  124. +24 −24 protoc_plugin/test/extension_test.dart
  125. +58 −58 protoc_plugin/test/file_generator_test.dart
  126. +5 −5 protoc_plugin/test/freeze_test.dart
  127. +46 −44 protoc_plugin/test/generated_message_test.dart
  128. +2 −1 protoc_plugin/test/golden_file.dart
  129. +6 −8 protoc_plugin/test/goldens/client
  130. +1 −1 protoc_plugin/test/goldens/grpc_service.pb
  131. +2 −1 protoc_plugin/test/goldens/grpc_service.pbgrpc
  132. +1 −1 protoc_plugin/test/goldens/header_in_package.pb
  133. +1 −1 protoc_plugin/test/goldens/header_with_fixnum.pb
  134. +1 −1 protoc_plugin/test/goldens/imports.pb
  135. +1 −1 protoc_plugin/test/goldens/imports.pbjson
  136. +1 −1 protoc_plugin/test/goldens/int64.pb
  137. +1 −1 protoc_plugin/test/goldens/oneMessage.pb
  138. +28 −28 protoc_plugin/test/goldens/oneMessage.pb.meta
  139. +1 −1 protoc_plugin/test/goldens/oneMessage.pbjson
  140. +4 −5 protoc_plugin/test/goldens/service.pb
  141. +1 −1 protoc_plugin/test/goldens/service.pbserver
  142. +1 −1 protoc_plugin/test/goldens/serviceGenerator.pb.json
  143. +1 −1 protoc_plugin/test/goldens/topLevelEnum.pb
  144. +1 −1 protoc_plugin/test/goldens/topLevelEnum.pbenum
  145. +10 −10 protoc_plugin/test/goldens/topLevelEnum.pbenum.meta
  146. +1 −1 protoc_plugin/test/goldens/topLevelEnum.pbjson
  147. +22 −22 protoc_plugin/test/hash_code_test.dart
  148. +8 −8 protoc_plugin/test/indenting_writer_test.dart
  149. +21 −14 protoc_plugin/test/json_test.dart
  150. +3 −3 protoc_plugin/test/leading_underscores_test.dart
  151. +18 −18 protoc_plugin/test/map_field_test.dart
  152. +16 −16 protoc_plugin/test/map_test.dart
  153. +1 −1 protoc_plugin/test/merge_test.dart
  154. +18 −16 protoc_plugin/test/message_generator_test.dart
  155. +274 −0 protoc_plugin/test/message_set_test.dart
  156. +75 −63 protoc_plugin/test/message_test.dart
  157. +5 −5 protoc_plugin/test/mirror_util.dart
  158. +22 −22 protoc_plugin/test/names_test.dart
  159. +1 −1 protoc_plugin/test/omit_field_names_test.dart
  160. +12 −12 protoc_plugin/test/oneof_test.dart
  161. +8 −8 protoc_plugin/test/proto3_json_test.dart
  162. +1 −1 protoc_plugin/test/proto3_optional_test.dart
  163. +6 −6 protoc_plugin/test/protoc_options_test.dart
  164. +1 −0 protoc_plugin/test/protos/foo.proto
  165. +32 −0 protoc_plugin/test/protos/message_set.proto
  166. +1 −1 protoc_plugin/test/repeated_field_test.dart
  167. +15 −14 protoc_plugin/test/reserved_names_test.dart
  168. +6 −6 protoc_plugin/test/service_generator_test.dart
  169. +21 −20 protoc_plugin/test/service_test.dart
  170. +4 −4 protoc_plugin/test/service_util.dart
  171. +26 −26 protoc_plugin/test/test_util.dart
  172. +6 −6 protoc_plugin/test/timestamp_test.dart
  173. +4 −4 protoc_plugin/test/to_builder_test.dart
  174. +52 −52 protoc_plugin/test/unknown_field_set_test.dart
  175. +1 −1 protoc_plugin/test/validate_fail_test.dart
  176. +8 −7 protoc_plugin/test/wire_format_test.dart
  177. +1 −1 tool/ci.sh
58 changes: 29 additions & 29 deletions .github/workflows/dart.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Created with package:mono_repo v6.5.4
# Created with package:mono_repo v6.5.7
name: Dart CI
on:
push:
@@ -35,27 +35,27 @@ jobs:
name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
- name: mono_repo self validate
run: dart pub global activate mono_repo 6.5.4
run: dart pub global activate mono_repo 6.5.7
- name: mono_repo self validate
run: dart pub global run mono_repo generate --validate
job_002:
name: "format_analyze; linux; Dart 2.12.0; PKG: protobuf; `dart analyze lib`, `dart analyze test`"
name: "format_analyze; linux; Dart 2.19.0; PKG: protobuf; `dart analyze lib`, `dart analyze test`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.12.0;packages:protobuf;commands:analyze_1-analyze_2"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf;commands:analyze_1-analyze_2"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;sdk:2.12.0;packages:protobuf
os:ubuntu-latest;pub-cache-hosted;sdk:2.12.0
os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf
os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: "2.12.0"
sdk: "2.19.0"
- id: checkout
name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
@@ -233,23 +233,23 @@ jobs:
if: "always() && steps.protoc_plugin_pub_upgrade.conclusion == 'success'"
working-directory: protoc_plugin
job_007:
name: "run_tests; linux; Dart 2.12.0; PKG: protobuf; `dart test`"
name: "run_tests; linux; Dart 2.19.0; PKG: protobuf; `dart test`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.12.0;packages:protobuf;commands:test_0"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf;commands:test_0"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;sdk:2.12.0;packages:protobuf
os:ubuntu-latest;pub-cache-hosted;sdk:2.12.0
os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf
os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: "2.12.0"
sdk: "2.19.0"
- id: checkout
name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
@@ -270,23 +270,23 @@ jobs:
- job_005
- job_006
job_008:
name: "run_tests; linux; Dart 2.17.0; PKG: protoc_plugin; `./../tool/setup.sh`, `make protos`, `dart test`"
name: "run_tests; linux; Dart 2.19.0; PKG: protoc_plugin; `./../tool/setup.sh`, `make protos`, `dart test`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:protoc_plugin;commands:command_0-command_3-test_0"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protoc_plugin;commands:command_0-command_3-test_0"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:protoc_plugin
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0
os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protoc_plugin
os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: "2.17.0"
sdk: "2.19.0"
- id: checkout
name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
@@ -397,23 +397,23 @@ jobs:
- job_005
- job_006
job_011:
name: "run_tests; osx; Dart 2.12.0; PKG: protobuf; `dart test`"
name: "run_tests; osx; Dart 2.19.0; PKG: protobuf; `dart test`"
runs-on: macos-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: "~/.pub-cache/hosted"
key: "os:macos-latest;pub-cache-hosted;sdk:2.12.0;packages:protobuf;commands:test_0"
key: "os:macos-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf;commands:test_0"
restore-keys: |
os:macos-latest;pub-cache-hosted;sdk:2.12.0;packages:protobuf
os:macos-latest;pub-cache-hosted;sdk:2.12.0
os:macos-latest;pub-cache-hosted;sdk:2.19.0;packages:protobuf
os:macos-latest;pub-cache-hosted;sdk:2.19.0
os:macos-latest;pub-cache-hosted
os:macos-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: "2.12.0"
sdk: "2.19.0"
- id: checkout
name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
@@ -471,13 +471,13 @@ jobs:
- job_005
- job_006
job_013:
name: "run_tests; windows; Dart 2.12.0; PKG: protobuf; `dart test`"
name: "run_tests; windows; Dart 2.19.0; PKG: protobuf; `dart test`"
runs-on: windows-latest
steps:
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: "2.12.0"
sdk: "2.19.0"
- id: checkout
name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
@@ -525,23 +525,23 @@ jobs:
- job_005
- job_006
job_015:
name: "run_legacy_tests; linux; Dart 2.17.0; PKG: protoc_plugin; `./../tool/setup.sh`, `make protos`, `dart test legacy_tests/generated_message_test.dart`"
name: "run_legacy_tests; linux; Dart 2.19.0; PKG: protoc_plugin; `./../tool/setup.sh`, `make protos`, `dart test legacy_tests/generated_message_test.dart`"
runs-on: ubuntu-latest
steps:
- name: Cache Pub hosted dependencies
uses: actions/cache@88522ab9f39a2ea568f7027eddc7d8d8bc9d59c8
with:
path: "~/.pub-cache/hosted"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:protoc_plugin;commands:command_0-command_3-test_1"
key: "os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protoc_plugin;commands:command_0-command_3-test_1"
restore-keys: |
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0;packages:protoc_plugin
os:ubuntu-latest;pub-cache-hosted;sdk:2.17.0
os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0;packages:protoc_plugin
os:ubuntu-latest;pub-cache-hosted;sdk:2.19.0
os:ubuntu-latest;pub-cache-hosted
os:ubuntu-latest
- name: Setup Dart SDK
uses: dart-lang/setup-dart@d6a63dab3335f427404425de0fbfed4686d93c4f
with:
sdk: "2.17.0"
sdk: "2.19.0"
- id: checkout
name: Checkout repository
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -9,3 +9,13 @@ packages
pubspec.lock
benchmarks/out
doc/

# `dart compile exe` outputs
*.exe

# `dart compile js` outputs
*.js*

# `dart compile wasm` outputs
*.wasm
*.mjs
18 changes: 6 additions & 12 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,22 +1,16 @@
include: package:lints/recommended.yaml
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-casts: true
errors:
lines_longer_than_80_chars: ignore

linter:
rules:
- always_declare_return_types
- avoid_bool_literals_in_conditional_expressions
- camel_case_types
- comment_references
- directives_ordering
- no_leading_underscores_for_local_identifiers
- omit_local_variable_types
- prefer_final_in_for_each
- prefer_final_locals
- prefer_relative_imports
- prefer_single_quotes
- prefer_spread_collections
- sort_pub_dependencies
- throw_in_finally
- type_annotate_public_apis
- unawaited_futures
- use_super_parameters
2 changes: 2 additions & 0 deletions api_benchmark/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -3,3 +3,5 @@ include: ../analysis_options.yaml
analyzer:
language:
strict-casts: false
errors:
only_throw_errors: ignore
24 changes: 12 additions & 12 deletions api_benchmark/lib/benchmark.dart
Original file line number Diff line number Diff line change
@@ -52,7 +52,7 @@ abstract class Benchmark {
{Profiler? profiler}) sync* {
checkRequest(r);

var sampleMillis = r.duration;
final sampleMillis = r.duration;
setup();

for (var i = 0; i < samples; i++) {
@@ -61,7 +61,7 @@ abstract class Benchmark {

if (profiler != null) {
profiler.startProfile(r);
var s = _measureOnce(sampleMillis);
final s = _measureOnce(sampleMillis);
profiler.endProfile(s);
}

@@ -84,7 +84,7 @@ abstract class Benchmark {
return 1;
}, 100);

var sample = _measureFor(exercise, sampleMillis);
final sample = _measureFor(exercise, sampleMillis);
setCounts(sample);
return sample;
}
@@ -121,10 +121,10 @@ abstract class Benchmark {
String summarizeResponse(pb.Response r) {
checkRequest(r.request);

var prefix = summary.padRight(39);
var sampleCount = r.samples.length.toStringAsFixed(0).padLeft(2);
var median = measureSample(medianSample(r)).toStringAsFixed(0).padLeft(4);
var max = measureSample(maxSample(r)).toStringAsFixed(0).padLeft(4);
final prefix = summary.padRight(39);
final sampleCount = r.samples.length.toStringAsFixed(0).padLeft(2);
final median = measureSample(medianSample(r)).toStringAsFixed(0).padLeft(4);
final max = measureSample(maxSample(r)).toStringAsFixed(0).padLeft(4);

return '$prefix samples: $sampleCount'
' median: $median max: $max $measureSampleUnits';
@@ -133,19 +133,19 @@ abstract class Benchmark {
/// Returns the sample with the median measurement.
pb.Sample? medianSample(pb.Response? response) {
if (response == null || response.samples.isEmpty) return null;
var samples = [...response.samples];
final samples = [...response.samples];
samples.sort((a, b) {
return measureSample(a).compareTo(measureSample(b));
});
var index = samples.length ~/ 2;
final index = samples.length ~/ 2;
return samples[index];
}

/// Returns the sample with the highest measurement.
pb.Sample? maxSample(pb.Response? response) {
if (response == null) return null;
pb.Sample? best;
for (var s in response.samples) {
for (final s in response.samples) {
best ??= s;
if (measureSample(best) < measureSample(s)) {
best = s;
@@ -166,10 +166,10 @@ abstract class Benchmark {
/// Executes [runner] repeatedly until [minimumMillis] has been reached.
/// [runner] should return the number of times it ran the benchmark.
static pb.Sample _measureFor(int Function() runner, int minimumMillis) {
var minimumMicros = minimumMillis * 1000;
final minimumMicros = minimumMillis * 1000;
var reps = 0;
var elapsed = 0;
var watch = Stopwatch()..start();
final watch = Stopwatch()..start();
while (elapsed < minimumMicros) {
reps += runner();
elapsed = watch.elapsedMicroseconds;
16 changes: 8 additions & 8 deletions api_benchmark/lib/benchmarks/get_strings.dart
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

import '../benchmark.dart';
import '../generated/benchmark.pb.dart'
show BenchmarkID, Request, Params, Sample;
show BenchmarkID, Params, Request, Sample;
import '../generated/string_grid.pb.dart' as pb;

/// A benchmark that accesses each value in a grid of string fields.
@@ -18,13 +18,13 @@ class GetStringsBenchmark extends Benchmark {

@override
String get summary {
var fill = fillValue == null ? 'null' : "'$fillValue'";
final fill = fillValue == null ? 'null' : "'$fillValue'";
return '${id.name}($height x $fill)';
}

@override
Params makeParams() {
var p = Params()..messageCount = height;
final p = Params()..messageCount = height;
if (fillValue != null) p.stringValue = fillValue!;
return p;
}
@@ -36,13 +36,13 @@ class GetStringsBenchmark extends Benchmark {

// makes a rectangle where every cell has the same value.
static pb.Grid10 _makeGrid(int height, String? fillValue) {
var grid = pb.Grid10();
final grid = pb.Grid10();

for (var y = 0; y < height; y++) {
var line = pb.Line10();
final line = pb.Line10();
if (fillValue != null) {
for (var x = 0; x < width; x++) {
var tag = getTagForColumn(line, x);
final tag = getTagForColumn(line, x);
line.setField(tag, fillValue);
}
}
@@ -76,7 +76,7 @@ class GetStringsBenchmark extends Benchmark {

void _getDefaults() {
var ok = true;
for (var line in grid.lines) {
for (final line in grid.lines) {
ok = ok && line.cell1.isEmpty;
ok = ok && line.cell2.isEmpty;
ok = ok && line.cell3.isEmpty;
@@ -93,7 +93,7 @@ class GetStringsBenchmark extends Benchmark {

void _getStrings() {
var ok = true;
for (var line in grid.lines) {
for (final line in grid.lines) {
ok = ok && line.cell1.isNotEmpty;
ok = ok && line.cell2.isNotEmpty;
ok = ok && line.cell3.isNotEmpty;
Loading