Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

introduce scoped logging & revise debug print #34

Merged
merged 7 commits into from
Jan 9, 2024
Merged

introduce scoped logging & revise debug print #34

merged 7 commits into from
Jan 9, 2024

Conversation

FObersteiner
Copy link
Collaborator

@FObersteiner FObersteiner commented Jan 8, 2024

  1. I noticed that there are debug prints in the build script; those can mix in with other console output if zbench is an indirect dependency (e.g. my check_filetimes demo for zdt got a "Failed to open directory x" since zbench is used in zdt). Scoped logging should avoid this. See also : https://ziggit.dev/t/best-practices-writing-to-stdout/2760

  2. Also, there seems to be mix of printing to stdout and stderr (std.debug.print). IMHO, this should be stdout only since we do not want to signal errors when running benchmarks (stderr output can be interpreted as exit(1)).

@FObersteiner
Copy link
Collaborator Author

@Bryysen you might want to check this PR


try bench.report();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to call Benchmark.report anymore now that Benchmark.prettyPrint displays the number of runs performed in the pretty-table

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, good point. Should we rename prettyPrint --> report then ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose? I don't have strong opinions on the naming either way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implemented via 4a8462b

@Bryysen
Copy link
Collaborator

Bryysen commented Jan 8, 2024

I'm still getting the "failed to open directory x" 😢

[****@**** index_map]$ zig build bench
warning(zbench_build): failed to open directory: util
benchmark                 runs     time (avg ± σ)         (min ............. max)      p75        p99        p995      
---------------------------------------------------------------------------------------------------------------------
...

Looks good otherwise!

@FObersteiner
Copy link
Collaborator Author

I'm still getting the "failed to open directory x" 😢

lol now at least you know where that message is coming from ;-) I think the problem is cwd, which in this case is the directory of your current project I assume, not zBench's.

@Bryysen
Copy link
Collaborator

Bryysen commented Jan 8, 2024

Yeah the error/warning is a lot more descriptive now at least. Should we then first detect whether std.fs.cwd() actually is "zBench" before starting to iterate through the test directiories? That seems like a brittle solution.. it's odd to me that we are descending into the test-setup part of build.zig when zBench is being compiled as a dependency in the first place :/

@FObersteiner
Copy link
Collaborator Author

FObersteiner commented Jan 8, 2024

it's odd to me that we are descending into the test-setup part of build.zig when zBench is being compiled as a dependency in the first place :/

Not sure why this was introduced, maybe zig didn't detect tests in all files? In general, I think a straight-forward solution for such a case would be to do that same as is currently being done for the examples. That way, you don't miss a file plus you don't need to obtain the cwd 'manually'. Described it here in more detail.

Besides, the build.zig will need a major revision for zig 0.12 anyway, a lot of changes seem to be made to the build-system right now.

@hendriknielaender
Copy link
Owner

it's odd to me that we are descending into the test-setup part of build.zig when zBench is being compiled as a dependency in the first place :/

Not sure why this was introduced, maybe zig didn't detect tests in all files? In general, I think a straight-forward solution for such a case would be to do that same as is currently being done for the examples. That way, you don't miss a file plus you don't need to obtain the cwd 'manually'. Described it here in more detail.

Besides, the build.zig will need a major revision for zig 0.12 anyway, a lot of changes seem to be made to the build-system right now.

Yeah I wanted to have a more dynamic solution for the test setup, since you can have tests next to the code. And not having only dedicated test files like: format_test.zig. But since this lib is not that huge so far, i also think we could revert this and use the same approach as mentioned.

I created a tracking issue for 0.12, so that we can already start migrating the codebase to 0.12.
#35

@hendriknielaender
Copy link
Owner

@Bryysen @FObersteiner please have a look into this PR, this should simplify the test setup.

#36

const version = std.SemanticVersion{ .major = 0, .minor = 1, .patch = 0 };
const log = std.log.scoped(.zbench_build);

const version = std.SemanticVersion{ .major = 0, .minor = 1, .patch = 2 };
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for bumping the version! 👍

@hendriknielaender hendriknielaender merged commit 060672b into hendriknielaender:main Jan 9, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants