add showing time taken for each solution
This commit is contained in:
parent
676dceec14
commit
8f9891cdde
@ -73,6 +73,7 @@ fn run(allocator: Allocator, args: *cli) !u8 {
|
|||||||
|
|
||||||
var input = aoc.Input{ .allocator = allocator, .lines = lines.items };
|
var input = aoc.Input{ .allocator = allocator, .lines = lines.items };
|
||||||
|
|
||||||
|
var start_time = std.time.microTimestamp();
|
||||||
var result: aoc.Result = undefined;
|
var result: aoc.Result = undefined;
|
||||||
if (args.part == 1) {
|
if (args.part == 1) {
|
||||||
result = try day.part1.?(&input);
|
result = try day.part1.?(&input);
|
||||||
@ -81,6 +82,7 @@ fn run(allocator: Allocator, args: *cli) !u8 {
|
|||||||
} else {
|
} else {
|
||||||
unreachable;
|
unreachable;
|
||||||
}
|
}
|
||||||
|
const end_time = std.time.microTimestamp();
|
||||||
|
|
||||||
switch (result) {
|
switch (result) {
|
||||||
.uint => std.debug.print("{}\n", .{result.uint}),
|
.uint => std.debug.print("{}\n", .{result.uint}),
|
||||||
@ -89,6 +91,9 @@ fn run(allocator: Allocator, args: *cli) !u8 {
|
|||||||
.text => std.debug.print("{s}\n", .{result.text}),
|
.text => std.debug.print("{s}\n", .{result.text}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const duration = end_time - start_time;
|
||||||
|
std.debug.print("Time taken: {}ms ({}us)\n", .{@divTrunc(duration, std.time.us_per_ms), duration});
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,7 +141,7 @@ fn get_input(allocator: Allocator, args: *cli) !u8 {
|
|||||||
return 255;
|
return 255;
|
||||||
}
|
}
|
||||||
|
|
||||||
const body = try request.reader().readAllAlloc(allocator, kilobytes(8));
|
const body = try request.reader().readAllAlloc(allocator, kilobytes(128));
|
||||||
defer allocator.free(body);
|
defer allocator.free(body);
|
||||||
|
|
||||||
var file = try std.fs.cwd().createFile(args.input_file, .{ });
|
var file = try std.fs.cwd().createFile(args.input_file, .{ });
|
||||||
|
Loading…
Reference in New Issue
Block a user