Skip to content

Commit

Permalink
Merge pull request #1558 from tigerbeetle/matklad/commit-time-stamp
Browse files Browse the repository at this point in the history
devhub: use commit timestamp to enable retrospective benchmarking
  • Loading branch information
matklad authored Feb 19, 2024
2 parents 789dff2 + bd97f10 commit 9c07bca
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/scripts/devhub.zig
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ pub const CliArgs = struct {
pub fn main(shell: *Shell, gpa: std.mem.Allocator, cli_args: CliArgs) !void {
_ = gpa;

const commit_timestamp_str =
try shell.exec_stdout("git show -s --format=%ct {sha}", .{ .sha = cli_args.sha });
const commit_timestamp = try std.fmt.parseInt(u64, commit_timestamp_str, 10);

var timer = try std.time.Timer.start();
try shell.zig("build -Drelease -Dconfig=production install", .{});
const build_time_ms = timer.lap() / std.time.ns_per_ms;
Expand All @@ -33,7 +37,9 @@ pub fn main(shell: *Shell, gpa: std.mem.Allocator, cli_args: CliArgs) !void {
const rss_bytes = try get_measurement(benchmark_result, "rss", "bytes");

try upload_run(shell, Run{
.timestamp = std.time.timestamp(),
// Use commit timestamp, rather wall clock time here. That way, it is possible to re-bench
// mark the entire history while getting a comparable time series.
.timestamp = commit_timestamp,
.revision = cli_args.sha,
.measurements = &[_]Measurement{
.{ .label = "build time", .value = build_time_ms, .unit = "ms" },
Expand All @@ -53,7 +59,7 @@ const Measurement = struct {
};

const Run = struct {
timestamp: i64,
timestamp: u64,
revision: []const u8,
measurements: []const Measurement,
};
Expand Down

0 comments on commit 9c07bca

Please sign in to comment.