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

Last change on this file since 868 was 868, checked in by sam, 12 years ago

test: add first test routines for the half class.

  • Property svn:keywords set to Id
File size: 1.1 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    uint16_t total = 0;
26    for (uint32_t i = 0; i < 0xffffffffu; i++)
27    {
28        union { float f; uint32_t x; } u;
29        u.x = i;
30
31        half h = half::makeslow(u.f);
32        total ^= h.bits();
33    }
34    Log::Info("time for makeslow: %f (hash %04x)\n", timer.GetMs(), total);
35
36    for (uint32_t i = 0; i < 0xffffffffu; i++)
37    {
38        union { float f; uint32_t x; } u;
39        u.x = i;
40
41        half h = half::makefast(u.f);
42        total ^= h.bits();
43    }
44    Log::Info("time for makefast: %f (hash %04x)\n", timer.GetMs(), total);
45
46    return EXIT_SUCCESS;
47}
48
Note: See TracBrowser for help on using the repository browser.