3 * Demonstration of ad-doc testing
5 * (c) 2024 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software: you can redistribute it and/or modify it under
13 * the terms of the GNU Library General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
17 * mLib is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 * License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib. If not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 /*----- Header files ------------------------------------------------------*/
35 #include "tvec-adhoc.h"
36 #include "tvec-bench.h"
37 #include "tvec-types.h"
41 /*----- Main code ---------------------------------------------------------*/
43 int main(int argc, char *argv[])
45 struct tvec_state tvstate;
47 unsigned long i, a, b, t;
50 tvec_parseargs(argc, argv, &tvstate, &argpos, &tvec_adhocconfig);
51 if (argpos < argc) die(2, "no input files expected");
53 TVEC_TESTGROUP(&tvstate, "fib-test") {
54 for (i = 0, a = 0, b = 1; i < FIBLIMIT; i++, t = b, b = a, a += t)
56 if (i < RECFIBLIMIT) TVEC_CLAIMEQ_UINT(&tvstate, a, recfib(i));
57 TVEC_CLAIMEQ_UINT(&tvstate, a, iterfib(i));
58 TVEC_CLAIMEQ_UINT(&tvstate, a, expfib(i));
62 TVEC_TESTGROUP(&tvstate, "fib-bench") {
65 if (tvec_benchprep(&tvstate, &tvec_benchstate, 0)) break;
67 dstr_reset(&d); dstr_putf(&d, "recfib, n = %u", RECFIBLIMIT);
68 TVEC_BENCHMARK(d.buf, &tvstate, tvec_benchstate, BTU_OP, 1)
69 while (_bench_n--) ADMIRE(recfib(RECFIBLIMIT));
71 dstr_reset(&d); dstr_putf(&d, "iterfib, n = %u", FIBLIMIT);
72 TVEC_BENCHMARK(d.buf, &tvstate, tvec_benchstate, BTU_OP, 1)
73 while (_bench_n--) ADMIRE(iterfib(FIBLIMIT));
75 dstr_reset(&d); dstr_putf(&d, "expfib, n = %u", FIBLIMIT);
76 TVEC_BENCHMARK(d.buf, &tvstate, tvec_benchstate, BTU_OP, 1)
77 while (_bench_n--) ADMIRE(expfib(FIBLIMIT));
81 return (tvec_end(&tvstate));
84 /*----- That's all, folks -------------------------------------------------*/