/* timings-arb - program to measure the efficiency of ARB Copyright 2001-2014 Free Software Foundation, Inc. Copyright 2001 Norbert Mueller (Univ. Trier, Germany). Copyright 2014 Fredrik Johansson. Contributed by the Arenaire and Caramel projects, INRIA. This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program; see the file COPYING.LESSER. If not, see http://www.gnu.org/licenses/ or write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include "gmp.h" #include "mpfr.h" #include "arb.h" #if defined (USG) || defined (__SVR4) || defined (_UNICOS) || defined(HPUX) #include int cputime () { if (CLOCKS_PER_SEC < 100000) return clock () * 1000 / CLOCKS_PER_SEC; return clock () / (CLOCKS_PER_SEC / 1000); } #else #include #include static int cputime () { struct rusage rus; getrusage (0, &rus); return rus.ru_utime.tv_sec * 1000 + rus.ru_utime.tv_usec / 1000; } #endif int main (int argc, char *argv[]) { int n, prec, st, st2, N, i; arb_t x, y, z; if (argc != 2 && argc != 3) { fprintf(stderr, "Usage: timing digits \n"); exit(1); } printf ("Using ARB-%s with FLINT-%s, MPFR-%s and GMP-%s\n", arb_version, FLINT_VERSION, mpfr_get_version (), gmp_version); n = atoi(argv[1]); prec = (int) ( n * log(10.0) / log(2.0) + 1.0 ); printf("[precision is %u bits]\n", prec); arb_init(x); arb_init(y); arb_init(z); arb_set_ui(x, 3); arb_sqrt(x, x, prec); arb_sub_ui(x, x, 1, prec); arb_set_ui(y, 5); arb_sqrt(y, y, prec); N=1; st = cputime(); do { for (i=0;i