initc3 / HoneyBadgerMPC

Robust MPC-based confidentiality layer for blockchains
GNU General Public License v3.0
128 stars 64 forks source link

Run benchmark tests "logic only" on Travis CI #451

Open sbellem opened 4 years ago

sbellem commented 4 years ago

The benchmark tests are run only once without reports.

Besides using the command line option --benchmark-disable to run the tests only once, a custom marker is used to select only one parameter value or tuple (a pytest param object) for test functions that are parameterized. The marker is named skip_bench for now :smile:. Here's an example of how this works:

@mark.parametrize(
    "t, k",
    [
        param(1, 5, marks=mark.skip_bench),
        (3, 5),
        (5, 5),
        # ...
    ],
)
def test_benchmark_hbavss_lite_dealer(test_router, benchmark, t, k): 
    # ...

The above test can then be run in three different ways:

  1. pytest -m skip_bench ... - only tests that are marked with skip_bench will be run;
  2. pytest -m "no skip_bench" ... - tests that are marked with skip_bench will be skipped, and
  3. pytest ... - (no marker is used) all tests will be run.

When the goal is to benchmark all, there's no need to know about this marker, and option 3 above will do. The main purpose is really for cases such as on Travis CI, in which one wishes to quickly check whether the tests run for a "subsample" of the parameters. Option 2, is not really useful, and is just a consequence of how the marker mechanism works.

If someone has a better idea for the name of the marker please say as I don't particularly like the name!

See the benchmark/README.md for more explanations.

Tiny issues were also fixed:

codecov[bot] commented 4 years ago

Codecov Report

Merging #451 into dev will increase coverage by 0.07129%. The diff coverage is n/a.

@@                 Coverage Diff                 @@
##                 dev        #451         +/-   ##
===================================================
+ Coverage   77.02727%   77.09856%   +0.07129%     
===================================================
  Files             50          50                 
  Lines           5611        5611                 
  Branches         859         859                 
===================================================
+ Hits            4322        4326          +4     
+ Misses          1113        1111          -2     
+ Partials         176         174          -2