[v4.1][PATCH] Framework for performance benchmarking of functions
Richard Henderson
rth@twiddle.net
Thu Mar 14 17:09:00 GMT 2013
On 03/14/2013 01:36 AM, Siddhesh Poyarekar wrote:
> Hi,
>
> I've updated the patch a bit because I found that in some cases the
> function calls were eliminated since their return values were not
> used. So here's v4.1
>
> Siddhesh
>
> * Makefile.in (bench): New target.
> * Rules (bench): Likewise.
> (binaries-bench): Generate binaries for functions to
> benchmark.
> * benchtests/Makefile: New makefile for benchmark tests.
> * benchtests/bench-skeleton.c: New skeleton file for benchmark
> programs.
> * benchtests/exp-inputs: New input file for EXP function.
> * benchtests/pow-inputs: New input file for POW function.
> * scripts/bench.pl: New script to generate source files for
> benchmark programs.
You should have tested at least i386, because you still didn't have the right
types in the printf for 32-bit.
> ./bench-skeleton.c:70:11: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘unsigned int’ [-Wformat]
Here's an incremental patch that fixes that and, IMO, makes the results more
readable.
arm cortex-A15:
Before:
> exp: ITERS:19033555374: TOTAL:4687423674997264089ns, MAX:187010.167000ns, MIN:5.253879ns, 0.000000/ms
> pow: ITERS:48073953056: TOTAL:4696356518798924186ns, MAX:468221.087000ns, MIN:2.080129ns, 0.000000/ms
After:
> exp: ITERS:100000: TOTAL:19.2022s, MAX:266889ns, MIN:190590ns, 5207.73 iter/s
> pow: ITERS:100000: TOTAL:47.5425s, MAX:482874ns, MIN:474051ns, 2103.38 iter/s
x86_64 core-i7:
Before:
> exp: ITERS:100000: TOTAL:9707826489ns, MAX:99094.620000ns, MIN:94726.611000ns, 10.300967/ms
> pow: ITERS:100000: TOTAL:22355547371ns, MAX:232855.636000ns, MIN:210420.638000ns, 4.473163/ms
After:
> exp: ITERS:100000: TOTAL:9.1457s, MAX:95778.7ns, MIN:90963ns, 10934.1 iter/s
> pow: ITERS:100000: TOTAL:21.1351s, MAX:223117ns, MIN:210674ns, 4731.47 iter/s
r~
-------------- next part --------------
diff --git a/benchtests/bench-skeleton.c b/benchtests/bench-skeleton.c
index 06be376..17453cc 100644
--- a/benchtests/bench-skeleton.c
+++ b/benchtests/bench-skeleton.c
@@ -64,10 +64,12 @@ main (int argc, char **argv)
}
}
- printf (FUNCNAME ": ITERS:%"PRId64": TOTAL:%"PRId64"ns, MAX:%lfns, "
- "MIN:%lfns, %lf/ms\n", ITER * NUM_SAMPLES, total,
- max / (double) iters, min / (double) iters,
- ITER * NUM_SAMPLES * 1e6 / total);
+ 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);
return 0;
}
More information about the Libc-alpha
mailing list