Skip to content

Commit c2e0af1

Browse files
committed
refactor: rename CurrentBenchmark to ExecutedBenchmark
1 parent acc213d commit c2e0af1

11 files changed

Lines changed: 171 additions & 171 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ codspeed run -- <your_cmd>
3030
To make sure your integration is fully working, you have to implement all these hooks:
3131
- start_benchmark: Call this when the benchmark starts, to start measuring the performance.
3232
- stop_benchmark: Stop measuring the performance after the benchmark stopped.
33-
- current_benchmark: Provide metadata about which benchmark was executed.
33+
- executed_benchmark: Provide metadata about which benchmark was executed.
3434
- set_integration: Provide metadata about the integration.
3535

3636
## Run tests

dist/core.c

Lines changed: 148 additions & 148 deletions
Large diffs are not rendered by default.

includes/core.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void instrument_hooks_deinit(InstrumentHooks *);
1515
bool instrument_hooks_is_instrumented(InstrumentHooks *);
1616
void instrument_hooks_start_benchmark(InstrumentHooks *);
1717
void instrument_hooks_stop_benchmark(InstrumentHooks *);
18-
void instrument_hooks_current_benchmark(InstrumentHooks *, int32_t pid, const char *uri);
18+
void instrument_hooks_executed_benchmark(InstrumentHooks *, int32_t pid, const char *uri);
1919
void instrument_hooks_set_integration(InstrumentHooks *, const char *name, const char *version);
2020

2121
void callgrind_start_instrumentation();

src/c.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,10 @@ pub export fn instrument_hooks_stop_benchmark(hooks: ?*InstrumentHooks) void {
5050
}
5151
}
5252

53-
pub export fn instrument_hooks_current_benchmark(hooks: ?*InstrumentHooks, pid: u32, uri: [*c]const u8) void {
53+
pub export fn instrument_hooks_executed_benchmark(hooks: ?*InstrumentHooks, pid: u32, uri: [*c]const u8) void {
5454
if (hooks) |h| {
55-
h.current_benchmark(pid, uri) catch |err| {
56-
std.debug.print("Failed to get current benchmark: {s}\n", .{@errorName(err)});
55+
h.set_executed_benchmark(pid, uri) catch |err| {
56+
std.debug.print("Failed to set executed benchmark: {s}\n", .{@errorName(err)});
5757
};
5858
}
5959
}
@@ -72,7 +72,7 @@ test "no crash when not instrumented" {
7272
_ = instrument_hooks_is_instrumented(instance);
7373
_ = instrument_hooks_start_benchmark(instance);
7474
_ = instrument_hooks_stop_benchmark(instance);
75-
_ = instrument_hooks_current_benchmark(instance, 0, "test");
75+
_ = instrument_hooks_executed_benchmark(instance, 0, "test");
7676
_ = instrument_hooks_set_integration(instance, "pytest-codspeed", "1.0");
7777

7878
instrument_hooks_deinit(instance);

src/instruments/perf.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ pub const PerfInstrument = struct {
4949
try self.reader.waitForAck(null);
5050
}
5151

52-
pub fn current_benchmark(self: *Self, pid: u32, uri: [*c]const u8) !void {
53-
try self.writer.sendCmd(fifo.Command{ .CurrentBenchmark = .{
52+
pub fn set_executed_benchmark(self: *Self, pid: u32, uri: [*c]const u8) !void {
53+
try self.writer.sendCmd(fifo.Command{ .ExecutedBenchmark = .{
5454
.pid = pid,
5555
.uri = std.mem.span(uri),
5656
} });
@@ -131,8 +131,8 @@ test "perf integration" {
131131
try std.testing.expect(si_result.equal(fifo.Command{ .SetIntegration = .{ .name = "zig", .version = "0.10.0" } }));
132132
si_result.deinit(allocator);
133133

134-
const cb_result = try tester.send(PerfInstrument.current_benchmark, .{ &perf, 42, "foo" });
135-
try std.testing.expect(cb_result.equal(fifo.Command{ .CurrentBenchmark = .{ .pid = 42, .uri = "foo" } }));
134+
const cb_result = try tester.send(PerfInstrument.set_executed_benchmark, .{ &perf, 42, "foo" });
135+
try std.testing.expect(cb_result.equal(fifo.Command{ .ExecutedBenchmark = .{ .pid = 42, .uri = "foo" } }));
136136
cb_result.deinit(allocator);
137137

138138
const start_result = try tester.send(PerfInstrument.start_benchmark, .{&perf});

src/instruments/root.zig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ pub const InstrumentHooks = union(enum) {
6161
}
6262
}
6363

64-
pub inline fn current_benchmark(self: *Self, pid: u32, uri: [*c]const u8) !void {
64+
pub inline fn set_executed_benchmark(self: *Self, pid: u32, uri: [*c]const u8) !void {
6565
switch (self.*) {
66-
.valgrind => ValgrindInstrument.current_benchmark(pid, uri),
67-
.perf => try self.perf.current_benchmark(pid, uri),
66+
.valgrind => ValgrindInstrument.set_executed_benchmark(pid, uri),
67+
.perf => try self.perf.set_executed_benchmark(pid, uri),
6868
.none => {},
6969
}
7070
}

src/instruments/valgrind.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub const ValgrindInstrument = struct {
3535
valgrind.callgrind_stop_instrumentation();
3636
}
3737

38-
pub inline fn current_benchmark(pid: u32, uri: [*c]const u8) void {
38+
pub inline fn set_executed_benchmark(pid: u32, uri: [*c]const u8) void {
3939
_ = pid;
4040
valgrind.callgrind_dump_stats_at(uri);
4141
}

src/shared.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pub const RUNNER_CTL_FIFO = "/tmp/runner.ctl.fifo";
66
pub const RUNNER_ACK_FIFO = "/tmp/runner.ack.fifo";
77

88
pub const Command = union(enum) {
9-
CurrentBenchmark: struct {
9+
ExecutedBenchmark: struct {
1010
pid: u32,
1111
uri: []const u8,
1212
},
@@ -26,7 +26,7 @@ pub const Command = union(enum) {
2626
allocator.free(data.name);
2727
allocator.free(data.version);
2828
},
29-
.CurrentBenchmark => |data| allocator.free(data.uri),
29+
.ExecutedBenchmark => |data| allocator.free(data.uri),
3030
else => {},
3131
}
3232
}
@@ -40,7 +40,7 @@ pub const Command = union(enum) {
4040
_ = fmt;
4141
_ = options;
4242
switch (self) {
43-
.CurrentBenchmark => |data| try writer.print("CurrentBenchmark {{ pid: {d}, uri: {s} }}", .{ data.pid, data.uri }),
43+
.ExecutedBenchmark => |data| try writer.print("ExecutedBenchmark {{ pid: {d}, uri: {s} }}", .{ data.pid, data.uri }),
4444
.StartBenchmark => try writer.writeAll("StartBenchmark"),
4545
.StopBenchmark => try writer.writeAll("StopBenchmark"),
4646
.Ack => try writer.writeAll("Ack"),
@@ -52,8 +52,8 @@ pub const Command = union(enum) {
5252

5353
pub fn equal(self: Command, other: Command) bool {
5454
return switch (self) {
55-
.CurrentBenchmark => |self_data| switch (other) {
56-
.CurrentBenchmark => |other_data| self_data.pid == other_data.pid and
55+
.ExecutedBenchmark => |self_data| switch (other) {
56+
.ExecutedBenchmark => |other_data| self_data.pid == other_data.pid and
5757
std.mem.eql(u8, self_data.uri, other_data.uri),
5858
else => false,
5959
},

src/tests/deserialize_rust/create_serialized.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
mod shared {
1919
#[derive(serde::Serialize, serde::Deserialize, Debug, PartialEq)]
2020
pub enum Command {
21-
CurrentBenchmark { pid: u32, uri: String },
21+
ExecutedBenchmark { pid: u32, uri: String },
2222
StartBenchmark,
2323
StopBenchmark,
2424
Ack,
@@ -47,7 +47,7 @@ fn main() {
4747

4848
example(
4949
"cmd_cur_bench",
50-
&shared::Command::CurrentBenchmark {
50+
&shared::Command::ExecutedBenchmark {
5151
pid: 12345,
5252
uri: "http://example.com/benchmark".to_string(),
5353
},

src/tests/deserialize_rust/rust_deser.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fn assert_eq(serialized: []const u8, expected_cmd: Command) !void {
1515
test "rust deserialization" {
1616
const rust = @import("serialized.zig");
1717

18-
try assert_eq(rust.cmd_cur_bench, Command{ .CurrentBenchmark = .{
18+
try assert_eq(rust.cmd_cur_bench, Command{ .ExecutedBenchmark = .{
1919
.pid = 12345,
2020
.uri = "http://example.com/benchmark",
2121
} });

0 commit comments

Comments
 (0)