Skip to content

Commit

Permalink
tests: hard code read_buf_cap to 4096
Browse files Browse the repository at this point in the history
* necessary for zig version 0.14.0-dev.3239+d7b93c787 where
  mem.page_size moved to heap.pageSize() and isn't always
  comptime known
  • Loading branch information
travisstaloch committed Feb 17, 2025
1 parent 2424355 commit 5ec9fae
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
7 changes: 4 additions & 3 deletions bench/twitter/main.zig
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const std = @import("std");

const dom = @import("simdjzon").dom;

pub const read_buf_cap = std.mem.page_size;
pub const read_buf_cap = 4096;

pub fn main() !u8 {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
Expand All @@ -21,8 +22,8 @@ pub fn main() !u8 {
const array = try statuses.get_array();
var i: usize = 0;
while (array.at(i)) |status| : (i += 1) {
_ = status; // autofix
// const id = try status.at_pointer("/id");
const id = try status.at_pointer("/id");
std.mem.doNotOptimizeAway(id);
// std.debug.print("{}\n", .{try id.get_int64()});
}
// std.debug.print("i={}\n", .{i});
Expand Down
6 changes: 3 additions & 3 deletions src/ondemand.zig
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ const CharUtils = string_parsing.CharUtils;

/// Users must specify `pub const read_buf_cap = N;` in their root source file.
/// This sets the static `ondemand.Parser.read_buf` size. `read_buf` is
/// where chunks of json source are stored. recommended `std.mem.page_size`.
/// where chunks of json source are stored. recommended `std.heap.pageSize()`.
/// Larger `read_buf_cap` may improve performance for large json files.
pub const READ_BUF_CAP = if (@hasDecl(root, "read_buf_cap"))
root.read_buf_cap
else if (builtin.is_test)
mem.page_size
4096
else
@compileError(
\\root source file is missing a `pub const read_buf_cap` declaration.
\\This sets the static `ondemand.Parser.read_buf` size. `read_buf` is
\\where chunks of json source are stored. recommended
\\`std.mem.page_size`.
\\`std.heap.pageSize()`.
\\
);

Expand Down
4 changes: 2 additions & 2 deletions src/tests.zig
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const std = @import("std");
const testing = std.testing;
const mem = std.mem;
const allr = testing.allocator;

const TapeType = dom.TapeType;
const simdjzon = @import("simdjzon");
const dom = simdjzon.dom;
const ondemand = simdjzon.ondemand;
const cmn = simdjzon.common;
const TapeType = dom.TapeType;

const allr = testing.allocator;
test "tape build 1" {
std.debug.print("\n", .{});
const f = try std.fs.cwd().openFile("test/test.json", .{});
Expand Down

0 comments on commit 5ec9fae

Please sign in to comment.