Skip to content

Commit b6996f5

Browse files
committed
chore: Reformat after sdk bump. Also _ is no longer a variable.
1 parent 484b4ed commit b6996f5

File tree

223 files changed

+12721
-12358
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+12721
-12358
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Future<void> main() async {
4747
final router = RelicRouter()
4848
..get('/user/:name/age/:age', hello)
4949
..use('/', logRequests())
50-
..fallback = respondWith((final _) => Response.notFound(
50+
..fallback = respondWith((_) => Response.notFound(
5151
body: Body.fromString("Sorry, that doesn't compute")));
5252
5353
// RelicRouter can be used directly as a handler via the call() extension

benchmark/benchmark.dart

Lines changed: 93 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -22,20 +22,22 @@ late final List<String> dynamicRoutesToLookup;
2222
void setupBenchmarkData(final int routeCount) {
2323
logger.info('Setting up benchmark data with $routeCount routes...');
2424
indexes = List.generate(routeCount, (final i) => i);
25-
final permutedIndexes = indexes.toList()
26-
..shuffle(Random(123)); // Use fixed seed for reproducibility
25+
final permutedIndexes =
26+
indexes.toList()
27+
..shuffle(Random(123)); // Use fixed seed for reproducibility
2728

2829
// Pre-generate lookup paths
2930
staticRoutesToLookup = permutedIndexes.map((final i) => '/path$i').toList();
30-
dynamicRoutesToLookup = permutedIndexes
31-
.map(
32-
(final i) =>
33-
// Fixed seed for reproducibility
34-
'/users/user_${Random(i).nextInt(1000)}'
35-
'/items/item_${Random(i + 1).nextInt(5000)}'
36-
'/profile$i',
37-
)
38-
.toList();
31+
dynamicRoutesToLookup =
32+
permutedIndexes
33+
.map(
34+
(final i) =>
35+
// Fixed seed for reproducibility
36+
'/users/user_${Random(i).nextInt(1000)}'
37+
'/items/item_${Random(i + 1).nextInt(5000)}'
38+
'/profile$i',
39+
)
40+
.toList();
3941
logger.info('Setup complete.');
4042
}
4143

@@ -65,7 +67,7 @@ class Emitter extends ScoreEmitterV2 {
6567

6668
abstract class RouterBenchmark extends PerfBenchmarkBase {
6769
RouterBenchmark(final Iterable<String> grouping, final Emitter emitter)
68-
: super(grouping.join(';'), emitter: emitter);
70+
: super(grouping.join(';'), emitter: emitter);
6971

7072
@override
7173
void exercise() => run();
@@ -74,7 +76,7 @@ abstract class RouterBenchmark extends PerfBenchmarkBase {
7476
// Benchmark for adding static routes
7577
class StaticAddBenchmark extends RouterBenchmark {
7678
StaticAddBenchmark(final Emitter emitter)
77-
: super(['Add', 'Static', 'x$routeCount', 'Router'], emitter);
79+
: super(['Add', 'Static', 'x$routeCount', 'Router'], emitter);
7880

7981
@override
8082
void run() {
@@ -88,7 +90,7 @@ class StaticAddBenchmark extends RouterBenchmark {
8890
// Benchmark for looking up static routes
8991
class StaticLookupBenchmark extends RouterBenchmark {
9092
StaticLookupBenchmark(final Emitter emitter)
91-
: super(['Lookup', 'Static', 'x$routeCount', 'Router'], emitter);
93+
: super(['Lookup', 'Static', 'x$routeCount', 'Router'], emitter);
9294

9395
late final Router<int> router;
9496

@@ -112,7 +114,7 @@ class StaticLookupBenchmark extends RouterBenchmark {
112114
// Benchmark for adding dynamic routes
113115
class DynamicAddBenchmark extends RouterBenchmark {
114116
DynamicAddBenchmark(final Emitter emitter)
115-
: super(['Add', 'Dynamic', 'x$routeCount', 'Router'], emitter);
117+
: super(['Add', 'Dynamic', 'x$routeCount', 'Router'], emitter);
116118

117119
@override
118120
void run() {
@@ -126,7 +128,7 @@ class DynamicAddBenchmark extends RouterBenchmark {
126128
// Benchmark for looking up dynamic routes
127129
class DynamicLookupBenchmark extends RouterBenchmark {
128130
DynamicLookupBenchmark(final Emitter emitter)
129-
: super(['Lookup', 'Dynamic', 'x$routeCount', 'Router'], emitter);
131+
: super(['Lookup', 'Dynamic', 'x$routeCount', 'Router'], emitter);
130132

131133
late final Router<int> router;
132134

@@ -150,7 +152,7 @@ class DynamicLookupBenchmark extends RouterBenchmark {
150152

151153
class StaticAddRoutingkitBenchmark extends RouterBenchmark {
152154
StaticAddRoutingkitBenchmark(final Emitter emitter)
153-
: super(['Add', 'Static', 'x$routeCount', 'Routingkit'], emitter);
155+
: super(['Add', 'Static', 'x$routeCount', 'Routingkit'], emitter);
154156

155157
@override
156158
void run() {
@@ -163,7 +165,7 @@ class StaticAddRoutingkitBenchmark extends RouterBenchmark {
163165

164166
class StaticLookupRoutingkitBenchmark extends RouterBenchmark {
165167
StaticLookupRoutingkitBenchmark(final Emitter emitter)
166-
: super(['Lookup', 'Static', 'x$routeCount', 'Routingkit'], emitter);
168+
: super(['Lookup', 'Static', 'x$routeCount', 'Routingkit'], emitter);
167169

168170
late final routingkit.Router<int> router;
169171

@@ -186,7 +188,7 @@ class StaticLookupRoutingkitBenchmark extends RouterBenchmark {
186188

187189
class DynamicAddRoutingkitBenchmark extends RouterBenchmark {
188190
DynamicAddRoutingkitBenchmark(final Emitter emitter)
189-
: super(['Add', 'Dynamic', 'x$routeCount', 'Routingkit'], emitter);
191+
: super(['Add', 'Dynamic', 'x$routeCount', 'Routingkit'], emitter);
190192

191193
@override
192194
void run() {
@@ -199,7 +201,7 @@ class DynamicAddRoutingkitBenchmark extends RouterBenchmark {
199201

200202
class DynamicLookupRoutingkitBenchmark extends RouterBenchmark {
201203
DynamicLookupRoutingkitBenchmark(final Emitter emitter)
202-
: super(['Lookup', 'Dynamic', 'x$routeCount', 'Routingkit'], emitter);
204+
: super(['Lookup', 'Dynamic', 'x$routeCount', 'Routingkit'], emitter);
203205

204206
late final routingkit.Router<int> router;
205207

@@ -223,7 +225,7 @@ class DynamicLookupRoutingkitBenchmark extends RouterBenchmark {
223225

224226
class StaticAddSpannerBenchmark extends RouterBenchmark {
225227
StaticAddSpannerBenchmark(final Emitter emitter)
226-
: super(['Add', 'Static', 'x$routeCount', 'Spanner'], emitter);
228+
: super(['Add', 'Static', 'x$routeCount', 'Spanner'], emitter);
227229

228230
@override
229231
void run() {
@@ -236,7 +238,7 @@ class StaticAddSpannerBenchmark extends RouterBenchmark {
236238

237239
class StaticLookupSpannerBenchmark extends RouterBenchmark {
238240
StaticLookupSpannerBenchmark(final Emitter emitter)
239-
: super(['Lookup', 'Static', 'x$routeCount', 'Spanner'], emitter);
241+
: super(['Lookup', 'Static', 'x$routeCount', 'Spanner'], emitter);
240242

241243
late final spanner.Spanner router;
242244

@@ -259,21 +261,24 @@ class StaticLookupSpannerBenchmark extends RouterBenchmark {
259261

260262
class DynamicAddSpannerBenchmark extends RouterBenchmark {
261263
DynamicAddSpannerBenchmark(final Emitter emitter)
262-
: super(['Add', 'Dynamic', 'x$routeCount', 'Spanner'], emitter);
264+
: super(['Add', 'Dynamic', 'x$routeCount', 'Spanner'], emitter);
263265

264266
@override
265267
void run() {
266268
final router = spanner.Spanner();
267269
for (final i in indexes) {
268270
router.addRoute(
269-
spanner.HTTPMethod.GET, '/users/<id>/items/<itemId>/profile$i', i);
271+
spanner.HTTPMethod.GET,
272+
'/users/<id>/items/<itemId>/profile$i',
273+
i,
274+
);
270275
}
271276
}
272277
}
273278

274279
class DynamicLookupSpannerBenchmark extends RouterBenchmark {
275280
DynamicLookupSpannerBenchmark(final Emitter emitter)
276-
: super(['Lookup', 'Dynamic', 'x$routeCount', 'Spanner'], emitter);
281+
: super(['Lookup', 'Dynamic', 'x$routeCount', 'Spanner'], emitter);
277282

278283
late final spanner.Spanner router;
279284

@@ -283,7 +288,10 @@ class DynamicLookupSpannerBenchmark extends RouterBenchmark {
283288
router = spanner.Spanner();
284289
for (final i in indexes) {
285290
router.addRoute(
286-
spanner.HTTPMethod.GET, '/users/<id>/items/<itemId>/profile$i', i);
291+
spanner.HTTPMethod.GET,
292+
'/users/<id>/items/<itemId>/profile$i',
293+
i,
294+
);
287295
}
288296
}
289297

@@ -297,36 +305,44 @@ class DynamicLookupSpannerBenchmark extends RouterBenchmark {
297305
}
298306

299307
enum RunOption<V> implements OptionDefinition<V> {
300-
file(FileOption(
301-
argName: 'output',
302-
argAbbrev: 'o',
303-
helpText: 'The file to write benchmark results to',
304-
fromDefault: _defaultFile,
305-
mode: PathExistMode.mustNotExist,
306-
)),
307-
308-
iterations(IntOption(
309-
argName: 'iterations',
310-
argAbbrev: 'i',
311-
helpText: 'Something to do with scale',
312-
defaultsTo: 1000,
313-
min: 1,
314-
)),
315-
316-
storeInNotes(FlagOption(
317-
argName: 'store-in-git-notes',
318-
argAbbrev: 's',
319-
helpText: 'Store benchmark result with git notes',
320-
defaultsTo: false,
321-
)),
322-
323-
pause(FlagOption(
324-
argName: 'pause-on-startup',
325-
argAbbrev: 'p',
326-
helpText: 'Pause on startup to allow devtools to attach',
327-
defaultsTo: false,
328-
hideNegatedUsage: true,
329-
));
308+
file(
309+
FileOption(
310+
argName: 'output',
311+
argAbbrev: 'o',
312+
helpText: 'The file to write benchmark results to',
313+
fromDefault: _defaultFile,
314+
mode: PathExistMode.mustNotExist,
315+
),
316+
),
317+
318+
iterations(
319+
IntOption(
320+
argName: 'iterations',
321+
argAbbrev: 'i',
322+
helpText: 'Something to do with scale',
323+
defaultsTo: 1000,
324+
min: 1,
325+
),
326+
),
327+
328+
storeInNotes(
329+
FlagOption(
330+
argName: 'store-in-git-notes',
331+
argAbbrev: 's',
332+
helpText: 'Store benchmark result with git notes',
333+
defaultsTo: false,
334+
),
335+
),
336+
337+
pause(
338+
FlagOption(
339+
argName: 'pause-on-startup',
340+
argAbbrev: 'p',
341+
helpText: 'Pause on startup to allow devtools to attach',
342+
defaultsTo: false,
343+
hideNegatedUsage: true,
344+
),
345+
);
330346

331347
const RunOption(this.option);
332348

@@ -384,10 +400,14 @@ class RunCommand extends BetterCommand<RunOption<dynamic>, void> {
384400
if (storeInNotes) {
385401
final head = await git.commitFromRevision('HEAD');
386402
logger.info('Appending benchmark results to: ${head.treeSha} (tree)');
387-
await git.runCommand(
388-
['notes', '--ref=benchmarks', 'append', '-F', file.path, head.treeSha],
389-
echoOutput: logger.shouldLog(LogLevel.debug),
390-
);
403+
await git.runCommand([
404+
'notes',
405+
'--ref=benchmarks',
406+
'append',
407+
'-F',
408+
file.path,
409+
head.treeSha,
410+
], echoOutput: logger.shouldLog(LogLevel.debug));
391411
}
392412
}
393413
}
@@ -419,9 +439,11 @@ class ExtractCommand extends BetterCommand<ExtractOption<dynamic>, void> {
419439
final to = commandConfig.value(ExtractOption.to);
420440

421441
final git = await GitDir.fromExisting(p.current, allowSubdirectory: true);
422-
final result = await git.runCommand(
423-
['log', '--format=%aI %H %T', '$from..$to'],
424-
);
442+
final result = await git.runCommand([
443+
'log',
444+
'--format=%aI %H %T',
445+
'$from..$to',
446+
]);
425447

426448
final sb = StringBuffer();
427449
for (final line in (result.stdout as String).split('\n')) {
@@ -433,10 +455,12 @@ class ExtractCommand extends BetterCommand<ExtractOption<dynamic>, void> {
433455
final treeSha = hashes[2];
434456
logger.debug('$commitSha $treeSha $authorTime');
435457

436-
final result = await git.runCommand(
437-
['notes', '--ref=benchmarks', 'show', treeSha],
438-
throwOnError: false,
439-
);
458+
final result = await git.runCommand([
459+
'notes',
460+
'--ref=benchmarks',
461+
'show',
462+
treeSha,
463+
], throwOnError: false);
440464
if (result.exitCode == 0) sb.writeln(result.stdout);
441465
}
442466
logger.info(sb.toString());
@@ -463,13 +487,8 @@ Future<int> main(final List<String> args) async {
463487
'Relic Benchmark Tool',
464488
setLogLevel: setLogLevel,
465489
enableCompletionCommand: true,
466-
embeddedCompletions: [
467-
completionScriptCarapace,
468-
],
469-
)..addCommands([
470-
RunCommand(),
471-
ExtractCommand(),
472-
]);
490+
embeddedCompletions: [completionScriptCarapace],
491+
)..addCommands([RunCommand(), ExtractCommand()]);
473492
try {
474493
await runner.run(args);
475494
} on UsageException catch (ex) {

example/advanced/multi_isolate.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,13 @@ void main() async {
1212

1313
// Wait for all the isolates to spawn
1414
log('Starting $isolateCount isolates');
15-
final isolates = await Future.wait(List.generate(
15+
final isolates = await Future.wait(
16+
List.generate(
1617
isolateCount,
1718
(final index) =>
18-
Isolate.spawn((final _) => _serve(), null, debugName: '$index')));
19+
Isolate.spawn((final _) => _serve(), null, debugName: '$index'),
20+
),
21+
);
1922

2023
// Wait for Ctrl-C before proceeding
2124
await ProcessSignal.sigint.watch().first;
@@ -29,9 +32,10 @@ void main() async {
2932
/// [_serve] is called in each spawned isolate.
3033
Future<void> _serve() async {
3134
// A router with no routes but a fallback
32-
final app = RelicApp()
33-
..use('/', logRequests())
34-
..put('/echo', respondWith(_echoRequest));
35+
final app =
36+
RelicApp()
37+
..use('/', logRequests())
38+
..put('/echo', respondWith(_echoRequest));
3539

3640
// start the server
3741
await app.serve(shared: true);

0 commit comments

Comments
 (0)