Skip to content

Commit 03085c6

Browse files
committed
chore: update bench
1 parent 2e96317 commit 03085c6

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

samples/bench/zig/build.zig

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,33 @@
11
const std = @import("std");
22

33
pub fn build(b: *std.Build) void {
4+
const optimize = b.standardOptimizeOption(.{});
5+
6+
const target_query = std.Target.Query{
7+
.cpu_arch = .wasm32,
8+
.os_tag = .freestanding,
9+
.cpu_features_add = std.Target.wasm.featureSet(&.{
10+
.simd128,
11+
.relaxed_simd,
12+
.tail_call,
13+
}),
14+
};
15+
const target = b.resolveTargetQuery(target_query);
16+
417
const lib = b.addExecutable(.{
518
.name = "zig",
6-
.root_source_file = b.path("main.zig"),
7-
.target = b.resolveTargetQuery(.{
8-
.cpu_arch = .wasm32,
9-
.os_tag = .freestanding,
10-
.cpu_features_add = std.Target.wasm.featureSet(&.{
11-
.simd128,
12-
.relaxed_simd,
13-
.tail_call,
14-
}),
19+
.root_module = b.createModule(.{
20+
.root_source_file = b.path("main.zig"),
21+
.target = target,
22+
.optimize = optimize,
1523
}),
1624
.use_llvm = true,
1725
.use_lld = true,
18-
.optimize = b.standardOptimizeOption(.{}),
1926
});
27+
2028
lib.entry = .disabled;
2129
lib.rdynamic = true;
2230
lib.want_lto = true;
31+
2332
b.installArtifact(lib);
2433
}

samples/bench/zig/main.zig

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ const opt = .{
77
.parse = std.json.ParseOptions{
88
.ignore_unknown_fields = true,
99
},
10-
.stringify = std.json.StringifyOptions{
11-
.whitespace = .minified,
12-
},
1310
};
1411

1512
pub const Data = struct {
@@ -27,12 +24,11 @@ export fn echoNumber() i32 {
2724
}
2825

2926
export fn echoStruct() u64 {
30-
_ = arena.reset(.retain_capacity);
27+
_ = arena.reset(.{ .retain_with_limit = std.math.maxInt(usize) });
3128
const input = decodeString(getStruct());
3229
const json = std.json.parseFromSlice(Data, ally, input, opt.parse) catch unreachable;
33-
var output = std.ArrayList(u8).init(ally);
34-
std.json.stringify(json.value, opt.stringify, output.writer()) catch unreachable;
35-
return encodeString(output.items);
30+
const output = std.json.Stringify.valueAlloc(ally, json.value, .{}) catch unreachable;
31+
return encodeString(output);
3632
}
3733

3834
export fn fi(n: i32) i32 {

0 commit comments

Comments
 (0)