[FYI wayland] tests: add noop to fixed-benchmark
Kristian Høgsberg
hoegsberg at gmail.com
Tue May 15 08:22:20 PDT 2012
On Tue, May 15, 2012 at 10:29:12AM +0300, Pekka Paalanen wrote:
> I was just curious of how much the looping takes time without
> conversion, so I added this.
>
> My results on Intel(R) Core(TM) i5-2410M CPU @ 2.30GHz:
>
> benchmarked noop: 1.876349827s
> benchmarked magic: 2.245844470s
> benchmarked div: 12.709085309s
> benchmarked mul: 7.504838141s
>
> Mul seems to take 15x the time magic does, cool!
Hmm, I get
8: 48 89 44 24 f8 mov %rax,-0x8(%rsp)
d: 48 83 c0 01 add $0x1,%rax
11: f2 0f 10 44 24 f8 movsd -0x8(%rsp),%xmm0
17: 48 3d ff ff ff 7f cmp $0x7fffffff,%rax
1d: f2 0f 11 05 00 00 00 movsd %xmm0,0x0(%rip) # 25 <noop_conversion+0x25>
24: 00
21: R_X86_64_PC32 global_d-0x4
25: 75 e1 jne 8 <noop_conversion+0x8>
and
benchmarked noop: 1.624387315s
benchmarked magic: 1.387375406s
benchmarked div: 8.840397131s
benchmarked mul: 5.192666376s
so it's a little wonky... just doing
for (f = 0; f < INT32_MAX; f++)
global_d = 1.0;
gives me
8: 48 ba 00 00 00 00 00 movabs $0x3ff0000000000000,%rdx
f: 00 f0 3f
12: 83 e8 01 sub $0x1,%eax
15: 48 89 15 00 00 00 00 mov %rdx,0x0(%rip) # 1c <noop_conversion+0x1c>
18: R_X86_64_PC32 global_d-0x4
1c: 75 ea jne 8 <noop_conversion+0x8>
and
benchmarked noop: 0.652343463s
benchmarked magic: 1.528544144s
benchmarked div: 8.675264684s
benchmarked mul: 5.123568706s
which is probably a more accurate estimate of just the loop overhead.
Either way, it's clear that the integer magic is faster by a good
margin, which is what I was trying to establish.
Kristian
> Btw. the simple default cast of int32_t to double is slower than magic
> for me, hence the use of union.
>
> Signed-off-by: Pekka Paalanen <ppaalanen at gmail.com>
> ---
> tests/fixed-benchmark.c | 16 ++++++++++++++++
> 1 files changed, 16 insertions(+), 0 deletions(-)
>
> diff --git a/tests/fixed-benchmark.c b/tests/fixed-benchmark.c
> index 3f7aae3..0d7abd0 100644
> --- a/tests/fixed-benchmark.c
> +++ b/tests/fixed-benchmark.c
> @@ -30,6 +30,21 @@
> volatile double global_d;
>
> static void
> +noop_conversion(void)
> +{
> + wl_fixed_t f;
> + union {
> + int64_t i;
> + double d;
> + } u;
> +
> + for (f = 0; f < INT32_MAX; f++) {
> + u.i = f;
> + global_d = u.d;
> + }
> +}
> +
> +static void
> magic_conversion(void)
> {
> wl_fixed_t f;
> @@ -80,6 +95,7 @@ benchmark(const char *s, void (*f)(void))
>
> int main(int argc, char *argv[])
> {
> + benchmark("noop", noop_conversion);
> benchmark("magic", magic_conversion);
> benchmark("div", div_conversion);
> benchmark("mul", mul_conversion);
> --
> 1.7.3.4
>
> _______________________________________________
> wayland-devel mailing list
> wayland-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/wayland-devel
More information about the wayland-devel
mailing list