<div dir="ltr">Thanks for the answer. <br><div><br></div><div>This solution will work very well.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Apr 29, 2019 at 10:17 AM Boris Kolpackov <<a href="mailto:boris@codesynthesis.com">boris@codesynthesis.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Luiz Fernando Afra Brito <<a href="mailto:luizfernandoafrabrito@gmail.com" target="_blank">luizfernandoafrabrito@gmail.com</a>> writes:<br>
<br>
> I started a lib project, then I implemented the data strutures in the<br>
> library subdirectory and some tests in the ``tests'' subdirectory. Now I<br>
> want a ``benchmarks'' subdirectory to code some benchmarks.<br>
> <br>
> I think it would be very convenient if I could type something like "b<br>
> benchmark", or something close, to run all benchmarks at once.<br>
<br>
I think inventing a new operation (which is what `b benchmark` would<br>
entail) is probably an overkill since it is essentially a variant of<br>
a test. Another common kind-of-like-test case is examples and we<br>
probably wouldn't want to also support `b example` or some such.<br>
<br>
On the other hand, if you put all your benchmarks into the benchmarks/<br>
subdirectory and run them as test, you can do:<br>
<br>
$ b test: benchmarks/<br>
<br>
Which I think is fairly close.<br>
<br>
<br>
> How woud you approach this problem using build2? Would you create<br>
> another exe project separated from the library or as an inner project<br>
> using the new --subdirectory flag? 'What is the best practice?<br>
<br>
The best practice is to create another subproject (in the build<br>
system terms) similar to tests/ (the same recommendatation would<br>
also apply to examples, BTW).<br>
<br>
While there is currently no bdep option to do this, it's pretty<br>
easy to achieve by simply copying the tests/ subdirectory, for<br>
example:<br>
<br>
$ cp -r tests/ benchmarks/<br>
<br>
Then you can rename benchmarks/basics/ to something more suitable,<br>
add more benchmarks next to it, etc.<br>
<br>
With this arrangement, whenever you run `b test` from the root of<br>
your project, you will also run the benchmarks. If you don't want<br>
that (for example, because they take too long), you can exclude<br>
benchmarks/ from the default target. To achieve this, replace<br>
the following line in your project's root buildfile:<br>
<br>
./: {*/ -build/} manifest<br>
<br>
With this:<br>
<br>
./: {*/ -build/ -benchmarks/} manifest<br>
./: benchmarks/: include = false<br>
<br>
Now to run benchmarks, you will have to explicitly specify this<br>
directory:<br>
<br>
$ b test: benchmarks/<br>
</blockquote></div>