forked from flutter/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding benchmarks for running in golem (flutter#142)
* first stab at a benchmark for running in golem.
- Loading branch information
Showing
46 changed files
with
1,646 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
analyzer: | ||
exclude: | ||
- benchmarks/query_benchmark/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:query_benchmark/generated/f0.pb.dart' as f0; | ||
import 'package:query_benchmark/benchmark.dart'; | ||
import 'package:query_benchmark/readfile.dart'; | ||
|
||
main() { | ||
String path = const String.fromEnvironment('testfile') ?? 'testdata/500.pb'; | ||
|
||
List<int> encoded = readfile(path); | ||
print( | ||
formatReport( | ||
title: 'protobuf_decode', | ||
duration: measure(() => f0.A0.fromBuffer(encoded)), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:query_benchmark/generated/f0.pb.dart' as f0; | ||
import 'package:query_benchmark/benchmark.dart'; | ||
import 'package:query_benchmark/readfile.dart'; | ||
|
||
main() { | ||
String path = const String.fromEnvironment('testfile') ?? 'testdata/500.pb'; | ||
|
||
List<int> encoded = readfile(path); | ||
f0.A0 a = f0.A0.fromBuffer(encoded); | ||
String json = a.writeToJson(); | ||
print( | ||
formatReport( | ||
title: 'protobuf_decode_json', | ||
duration: measure(() => f0.A0.fromJson(json)), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:query_benchmark/generated/f0.pb.dart' as f0; | ||
import 'package:query_benchmark/benchmark.dart'; | ||
import 'package:query_benchmark/readfile.dart'; | ||
|
||
main() { | ||
String path = const String.fromEnvironment('testfile') ?? 'testdata/500.pb'; | ||
List<int> encoded = readfile(path); | ||
f0.A0 a = f0.A0.fromBuffer(encoded); | ||
print( | ||
formatReport( | ||
title: 'protobuf_encode', | ||
duration: measure(() => a.writeToBuffer()), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:query_benchmark/generated/f0.pb.dart' as f0; | ||
import 'package:query_benchmark/benchmark.dart'; | ||
import 'package:query_benchmark/readfile.dart'; | ||
|
||
main() { | ||
String path = const String.fromEnvironment('testfile') ?? 'testdata/500.pb'; | ||
|
||
List<int> encoded = readfile(path); | ||
f0.A0 a = f0.A0.fromBuffer(encoded); | ||
print( | ||
formatReport( | ||
title: 'protobuf_encode_json', | ||
duration: measure(() => a.writeToJson()), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'package:query_benchmark/generated/f0.pb.dart' as f0; | ||
import 'package:query_benchmark/generated/f2.pb.dart' as f2; | ||
import 'package:query_benchmark/generated/f19.pb.dart' as f19; | ||
import 'package:query_benchmark/benchmark.dart'; | ||
import 'package:query_benchmark/readfile.dart'; | ||
|
||
main() { | ||
String path = const String.fromEnvironment('testfile') ?? 'testdata/500.pb'; | ||
|
||
List<int> encoded = readfile(path); | ||
f0.A0 a = f0.A0.fromBuffer(encoded)..freeze(); | ||
print( | ||
formatReport( | ||
title: 'protobuf_decode', | ||
duration: measure(() => a.copyWith((f0.A0 a0Builder) { | ||
a0Builder.a4.last = a0Builder.a4.last.copyWith((f2.A1 a1builder) { | ||
a1builder.a378.copyWith( | ||
(f19.A220 a220builder) => a220builder.a234 = 'new_value'); | ||
}); | ||
})), | ||
), | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/usr/bin/env bash | ||
rm -rf lib/generated | ||
mkdir lib/generated | ||
protoc --dart_out=lib/generated --plugin=protoc-gen-dart=run_protoc_plugin.sh -Iprotos protos/*.proto | ||
dartfmt -w lib/generated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
/// Returns the average time to execute [f] over [iterations] repetitions. | ||
/// | ||
/// Will first run [f] [warmupIterations] times to warm up the runtime. | ||
Duration measure(void Function() f, | ||
{int warmupIterations = 100, int iterations = 1000}) { | ||
for (int i = 0; i < warmupIterations; i++) { | ||
f(); | ||
} | ||
var s = Stopwatch()..start(); | ||
for (int i = 0; i < iterations; i++) { | ||
f(); | ||
} | ||
return s.elapsed ~/ iterations; | ||
} | ||
|
||
String formatReport({String title, Duration duration}) { | ||
return "RunTimeRaw($title): ${duration.inMicroseconds} us"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
export 'readfile_vm.dart' if (dart.library.js) 'readfile_d8.dart' show readfile; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:js' as js; | ||
|
||
import 'dart:typed_data'; | ||
|
||
/// Reads the file at the given [path] and return its contents in a List<int>. | ||
Uint8List readfile(String path) { | ||
// d8 specific implementation. | ||
js.JsObject jsArrayBuffer = js.context.callMethod('readbuffer', [path]); | ||
int length = jsArrayBuffer['byteLength']; | ||
js.JsObject jsInt8View = | ||
new js.JsObject(js.context['Int8Array'], [jsArrayBuffer]); | ||
Uint8List result = new Uint8List(length); | ||
for (int i = 0; i < length; i++) { | ||
result[i] = jsInt8View[i]; | ||
} | ||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
import 'dart:io'; | ||
|
||
List<int> readfile(String path) { | ||
return new File(path).readAsBytesSync(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# See https://github.com/dart-lang/mono_repo for details | ||
dart: | ||
- stable | ||
|
||
stages: | ||
- format_analyzer_tests: | ||
- group: | ||
- command: ./compile_protos.sh | ||
- dartfmt | ||
- dartanalyzer: --fatal-warnings . | ||
dart: [stable] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
syntax = "proto2"; | ||
package a0.a1.a2.a3; | ||
import "f2.proto"; | ||
import "f3.proto"; | ||
message A0 { | ||
repeated .a0.a1.a2.a3.A1 a4 = 1; | ||
optional string a5 = 3; | ||
enum A2 { | ||
A3 = 0; | ||
A4 = 1; | ||
A5 = 2; | ||
A6 = 3; | ||
A7 = 4; | ||
A8 = 5; | ||
} | ||
optional A2 a6 = 2; | ||
optional a7.A9 a8 = 4; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
syntax = "proto2"; | ||
package a0.a1.a274; | ||
import "f5.proto"; | ||
message A313 { | ||
optional int32 a90 = 1; | ||
optional int32 a275 = 2; | ||
} | ||
message A314 { | ||
repeated A313 a276 = 1; | ||
} | ||
message A315 { | ||
optional string a277 = 1; | ||
optional a10.A113.A59 a99 = 2; | ||
optional int64 a278 = 3; | ||
repeated string a279 = 4; | ||
} | ||
message A316 { | ||
optional string a280 = 1; | ||
optional int64 a281 = 2; | ||
repeated A315 a282 = 3; | ||
} | ||
message A317 { | ||
repeated A316 a283 = 1; | ||
} | ||
extend a10.A56 { | ||
repeated A313 a276 = 134096400; | ||
optional A314 a284 = 141473177; | ||
} | ||
message A318 { | ||
message A319 { | ||
optional int32 a285 = 1; | ||
optional string a54 = 2; | ||
} | ||
repeated A319 a286 = 1; | ||
} | ||
extend a10.A57 { | ||
optional int32 a287 = 134096400; | ||
optional A318 a288 = 185706300; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
syntax = "proto2"; | ||
package a10.a68; | ||
message A102 { | ||
optional string a52 = 1; | ||
optional uint64 a69 = 2; | ||
optional uint64 a70 = 3; | ||
optional uint64 a71 = 4; | ||
} | ||
message A103 { | ||
optional string a52 = 1; | ||
optional uint64 a72 = 2; | ||
repeated A102 a73 = 3; | ||
} | ||
message A104 { | ||
repeated A103 message = 1; | ||
optional string a74 = 2; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright (c) 2018, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
|
||
syntax = "proto2"; | ||
package a0.a1; | ||
import "f12.proto"; | ||
message A105 { | ||
optional string a75 = 1; | ||
}; | ||
message A106 { | ||
optional A105 a76 = 1; | ||
optional string a77 = 3; | ||
}; | ||
message A107 { | ||
optional string a78 = 1; | ||
} |
Oops, something went wrong.