-
-
Notifications
You must be signed in to change notification settings - Fork 874
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master'
- Loading branch information
Showing
81 changed files
with
1,718 additions
and
1,704 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,107 @@ | ||
import 'dart:async'; | ||
import 'dart:math' as math; | ||
|
||
import 'package:flutter_map/src/geo/crs.dart'; | ||
import 'package:latlong2/latlong.dart'; | ||
import 'package:logger/logger.dart'; | ||
|
||
class NoFilter extends LogFilter { | ||
@override | ||
bool shouldLog(LogEvent event) => true; | ||
} | ||
|
||
typedef Result = ({ | ||
String name, | ||
Duration duration, | ||
}); | ||
|
||
Future<Result> timedRun(String name, dynamic Function() body) async { | ||
Logger().i('running $name...'); | ||
final watch = Stopwatch()..start(); | ||
await body(); | ||
watch.stop(); | ||
|
||
return (name: name, duration: watch.elapsed); | ||
} | ||
|
||
// NOTE: to have a more prod like comparison, run with: | ||
// $ dart compile exe benchmark/crs.dart && ./benchmark/crs.exe | ||
// | ||
// If you run in JIT mode, the resulting execution times will be a lot more similar. | ||
Future<void> main() async { | ||
Logger.level = Level.all; | ||
Logger.defaultFilter = () => NoFilter(); | ||
Logger.defaultPrinter = () => SimplePrinter(); | ||
|
||
final results = <Result>[]; | ||
const N = 100000000; | ||
|
||
const crs = Epsg3857(); | ||
results.add(await timedRun('Concrete type: ${crs.code}.latLngToXY()', () { | ||
double x = 0; | ||
double y = 0; | ||
for (int i = 0; i < N; ++i) { | ||
final latlng = LatLng((i % 90).toDouble(), (i % 180).toDouble()); | ||
final (cx, cy) = crs.latLngToXY(latlng, 1); | ||
x += cx; | ||
y += cy; | ||
} | ||
return x + y; | ||
})); | ||
|
||
results.add(await timedRun('Concrete type: ${crs.code}.latLngToPoint()', () { | ||
double x = 0; | ||
double y = 0; | ||
for (int i = 0; i < N; ++i) { | ||
final latlng = LatLng((i % 90).toDouble(), (i % 180).toDouble()); | ||
final p = crs.latLngToPoint(latlng, 1); | ||
x += p.x; | ||
y += p.y; | ||
} | ||
return x + y; | ||
})); | ||
|
||
const crss = <Crs>[ | ||
Epsg3857(), | ||
Epsg4326(), | ||
]; | ||
|
||
for (final crs in crss) { | ||
results.add(await timedRun('${crs.code}.latLngToXY()', () { | ||
double x = 0; | ||
double y = 0; | ||
for (int i = 0; i < N; ++i) { | ||
final latlng = LatLng((i % 90).toDouble(), (i % 180).toDouble()); | ||
final (cx, cy) = crs.latLngToXY(latlng, 1); | ||
x += cx; | ||
y += cy; | ||
} | ||
return x + y; | ||
})); | ||
|
||
results.add(await timedRun('${crs.code}.latlngToPoint()', () { | ||
double x = 0; | ||
double y = 0; | ||
for (int i = 0; i < N; ++i) { | ||
final latlng = LatLng((i % 90).toDouble(), (i % 180).toDouble()); | ||
final point = crs.latLngToPoint(latlng, 1); | ||
x += point.x; | ||
y += point.y; | ||
} | ||
return x + y; | ||
})); | ||
|
||
results.add(await timedRun('${crs.code}.pointToLatLng()', () { | ||
double x = 0; | ||
double y = 0; | ||
for (int i = 0; i < N; ++i) { | ||
final latlng = crs.pointToLatLng(math.Point<double>(x, y), 1); | ||
x += latlng.longitude; | ||
y += latlng.latitude; | ||
} | ||
return x + y; | ||
})); | ||
} | ||
|
||
Logger().i('Results:\n${results.map((r) => r.toString()).join('\n')}'); | ||
} |
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 |
---|---|---|
@@ -1,30 +1,8 @@ | ||
include: package:flutter_lints/flutter.yaml | ||
|
||
analyzer: | ||
language: | ||
strict-casts: true | ||
strict-inference: true | ||
strict-raw-types: true | ||
errors: | ||
missing_required_param: error | ||
missing_return: error | ||
# match the lint rules from flutter_map | ||
include: ./../analysis_options.yaml | ||
|
||
# only specify things that should be different from the package | ||
linter: | ||
rules: | ||
library_private_types_in_public_api: false # Not relevant to the example | ||
|
||
always_declare_return_types: true | ||
always_use_package_imports: true | ||
avoid_dynamic_calls: true | ||
cancel_subscriptions: true | ||
close_sinks: false | ||
package_api_docs: true | ||
prefer_constructors_over_static_methods: true | ||
prefer_final_in_for_each: true | ||
prefer_final_locals: true | ||
prefer_int_literals: true | ||
test_types_in_equals: true | ||
throw_in_finally: true | ||
type_annotate_public_apis: true | ||
unnecessary_statements: true | ||
use_named_constants: true | ||
# using the default parameter values are used as explanation and for showcase | ||
avoid_redundant_argument_values: false |
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
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
2 changes: 1 addition & 1 deletion
2
.../kotlin/me/jpryan/example/MainActivity.kt → ...aflet/flutter_map/example/MainActivity.kt
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
6 changes: 0 additions & 6 deletions
6
example/android/app/src/main/kotlin/me/jpryan/flutter_map_example/MainActivity.kt
This file was deleted.
Oops, something went wrong.
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
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
org.gradle.jvmargs=-Xmx1536M | ||
org.gradle.jvmargs=-Xmx4G | ||
android.useAndroidX=true | ||
android.enableJetifier=true |
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
Oops, something went wrong.