source: trunk/test/lol-bench.cpp @ 870

Last change on this file since 870 was 870, checked in by sam, 8 years ago

test: augment the half precision numbers testsuite.

  • Property svn:keywords set to Id
File size: 1.4 KB
Line 
1//
2// Lol Engine - Benchmark program
3//
4// Copyright: (c) 2005-2011 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://sam.zoy.org/projects/COPYING.WTFPL for more details.
9//
10
11#if defined HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#include "core.h"
16#include "loldebug.h"
17
18using namespace std;
19using namespace lol;
20
21int main(int argc, char **argv)
22{
23    Timer timer;
24
25    float ftotal = 0.0f;
26    for (uint32_t i = 0; i < 0xffffffffu; i += 7)
27    {
28        union { float f; uint32_t x; } u;
29        u.x = i;
30
31        float h = (float)half::makefast(u.f);
32        ftotal += h;
33    }
34    Log::Info("time for makeslow: %f (hash %f)\n", timer.GetMs(), ftotal);
35
36    uint16_t total = 0;
37    for (uint32_t i = 0; i < 0xffffffffu; i += 7)
38    {
39        union { float f; uint32_t x; } u;
40        u.x = i;
41
42        half h = half::makeslow(u.f);
43        total ^= h.bits();
44    }
45    Log::Info("time for makeslow: %f (hash %04x)\n", timer.GetMs(), total);
46
47    for (uint32_t i = 0; i < 0xffffffffu; i += 7)
48    {
49        union { float f; uint32_t x; } u;
50        u.x = i;
51
52        half h = half::makefast(u.f);
53        total ^= h.bits();
54    }
55    Log::Info("time for makefast: %f (hash %04x)\n", timer.GetMs(), total);
56
57    return EXIT_SUCCESS;
58}
59
Note: See TracBrowser for help on using the repository browser.