-
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.
Write a util to time each part function, and
refactor all existing solutions to use it. Add a new entrypoint to run all days against both sample and real data.
- Loading branch information
1 parent
1976c5f
commit de924a9
Showing
10 changed files
with
58 additions
and
25 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import 'day1.dart' as day1; | ||
import 'day2.dart' as day2; | ||
import 'day3.dart' as day3; | ||
import 'day4.dart' as day4; | ||
import 'day5.dart' as day5; | ||
import 'day6.dart' as day6; | ||
|
||
void main(List<String> arguments) async { | ||
print(''); | ||
for (final day in [day1.main, day2.main, day3.main, day4.main, day5.main, day6.main]) { | ||
await day(arguments); | ||
print(''); | ||
} | ||
} | ||
|
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
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 +1,2 @@ | ||
export 'shared/resources.dart'; | ||
export 'shared/runner.dart'; |
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,27 @@ | ||
import 'resources.dart'; | ||
|
||
typedef DayFunction = Future<int> Function(Resources); | ||
|
||
final _stopwatch = Stopwatch(); | ||
|
||
/// Runs both parts for a day, and prints their output as well as the | ||
/// elapsed time to run each part. | ||
Future<void> runDay( | ||
{required final int day, | ||
required final DayFunction part1, | ||
required final DayFunction part2}) async { | ||
print('Advent of Code - Day $day'); | ||
for (final resource in [Resources.sample, Resources.real]) { | ||
print('- $resource data:'); | ||
|
||
for (final part in [(1, part1), (2, part2)]) { | ||
_stopwatch.reset(); | ||
_stopwatch.start(); | ||
final result = await part.$2(resource); | ||
_stopwatch.stop(); | ||
|
||
print( | ||
' - Part ${part.$1}: $result (${_stopwatch.elapsedMilliseconds}ms)'); | ||
} | ||
} | ||
} |