summaryrefslogtreecommitdiff
path: root/cesar/test_general/proto_gaisler/src/test_speed.c
blob: aa9242b6fb79536f7697900b383b2e877818921d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/* Cesar project {{{
 *
 * Copyright (C) 2007 Spidcom
 *
 * <<<Licence>>>
 *
 * }}} */
/**
 * \file    ./src/test_speed.c
 * \brief   « brief description »
 * \ingroup « module »
 *
 * « long description »
 */

#include "common/std.h"
#include "sys/time.h"
#include "stdio.h"
#include "string.h"
#include "math.h"


int
main (int argc, char **argv)
{
    struct timeval tv0, tv1;
    double test_d;
    int r;
    double flottant = 0.123456789;
    double res = flottant;
    double x=0;

    gettimeofday (&tv0, NULL);
    for (r=-10000; r<10000; r++)
    {
        x = (double)(M_PI*r)/ 10000.0;
        for (test_d=0; test_d<100; test_d++)
        {
            res = test_d * x;
        }
    }
    gettimeofday (&tv1, NULL);
    printf ("test duration [mux] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec)));
    gettimeofday (&tv0, NULL);
    for (r=-10000; r<10000; r++)
    {
        x = (double)(M_PI*r)/ 10000.0;
        for (test_d=0; test_d<100; test_d++)
        {
            res = test_d / x;
        }
    }
    gettimeofday (&tv1, NULL);
    printf ("test duration [div : dble/dble] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec)));
    gettimeofday (&tv0, NULL);
    for (r=-10000; r<10000; r++)
    {
        x = (double)(M_PI*r)/ 10000.0;
        for (test_d=0; test_d<100; test_d++)
        {
            res = sin (x);
        }
    }
    gettimeofday (&tv1, NULL);
    printf ("test duration [sin (dble)] %d \n", (int) ((tv1.tv_sec*1000000+tv1.tv_usec)-(tv0.tv_sec*1000000 + tv0.tv_usec)));
    return 0;
}