This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] randomize benchtests


On 22 April 2013 17:30, OndÅej BÃlka <neleai@seznam.cz> wrote:
>    uint64_t total = 0, max = 0, min = 0x7fffffffffffffff;
>    struct timespec start, end;
> -
> +  int seed = 42;

You get the same sequence all the time.  Use getpid() as seed or even time().

> +      clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &start);
> +      for (k = 0; k < iters; k++)
> +        {
> +         i = rand_r (&seed)%NUM_SAMPLES;
> +         BENCH_FUNC(i);
> +        }
> +      clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &end);

This is wrong.  The interval also has the time taken to call rand_r.

> -  double d_total_s = total * 1e-9;
> -  double d_iters = iters;
>    double d_total_i = (double)ITER * NUM_SAMPLES;
> -  printf (FUNCNAME ": ITERS:%g: TOTAL:%gs, MAX:%gns, MIN:%gns, %g iter/s\n",
> -         d_total_i, d_total_s, max / d_iters, min / d_iters,
> -         d_total_i / d_total_s);
> +  printf (FUNCNAME ": AVERAGE:%gns\tMIN:%gns,\tMAX:%gns\n",
> +               d_total / d_total_i, min / iters, max / iters);

If you have total iterations and iters/sec, you can compute average
directly.  You've gotten rid of two pieces of core information to add
one piece of derived information.  I am not very picky about what the
output looks like though.

Also, if you wait for the HP_TIMING patch to be reviewed and checked
in, you'll get cycles as a unit instead of nanoseconds.

Siddhesh
--
http://siddhesh.in


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]