OpenCores
URL https://opencores.org/ocsvn/c0or1k/c0or1k/trunk

Subversion Repositories c0or1k

[/] [c0or1k/] [trunk/] [conts/] [test_suite0/] [src/] [perf/] [getid.c] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 drasko
/*
2
 * Copyright (C) 2010 B Labs Ltd.
3
 *
4
 * l4_getid performance tests
5
 *
6
 * Author: Bahadir Balban
7
 */
8
#include <l4lib/macros.h>
9
#include L4LIB_INC_ARCH(syslib.h)
10
#include L4LIB_INC_ARCH(syscalls.h)
11
#include <l4lib/lib/thread.h>
12
#include <l4lib/perfmon.h>
13
#include <perf.h>
14
#include <tests.h>
15
#include <string.h>
16
#include <timer.h>
17
 
18
struct perfmon_cycles l4_getid_cycles;
19
 
20
#define PERFTEST_GETID_COUNT            100
21
 
22
/*
23
 * Measure l4_getid by timer ticks
24
 */
25
void perf_measure_getid_ticks(void)
26
{
27
        const int timer_ldval = 0xFFFFFFFF;
28
        unsigned int timer_val, timer_stamp = 0xFFFFFFFF;
29
        unsigned int min = ~0, max = 0, last = 0, total = 0, ops = 0;
30
        struct task_ids ids;
31
 
32
        /* Make sure timer is disabled */
33
        timer_stop(timer_base);
34
 
35
        /* Configure timer as one shot */
36
        timer_init_oneshot(timer_base);
37
 
38
        /* Load the timer with ticks value */
39
        timer_load(timer_ldval, timer_base);
40
 
41
        /* Start the timer */
42
        printf("Starting the l4_getid timer tick test.\n");
43
        timer_start(timer_base);
44
 
45
        /* Do the operation */
46
        for (int i = 0; i < PERFTEST_GETID_COUNT; i++) {
47
                l4_getid(&ids);
48
                timer_val = timer_read(timer_base);
49
                last = timer_stamp - timer_val;
50
                timer_stamp = timer_val;
51
                if (min > last)
52
                        min = last;
53
                if (max < last)
54
                        max = last;
55
                ops++;
56
                total += last;
57
        }
58
 
59
        printf("TIMER: l4_getid took each %u min, %u max, %u avg,\n"
60
               "%u total microseconds, and %u total ops\n", min,
61
               max, total/ops, total, ops);
62
}
63
 
64
/*
65
 * Measure l4_getid by cpu cycles
66
 */
67
void perf_measure_getid(void)
68
{
69
        struct task_ids ids;
70
 
71
        /*
72
         * Initialize structures
73
         */
74
        memset(&l4_getid_cycles, 0, sizeof (l4_getid_cycles));
75
        l4_getid_cycles.min = ~0; /* Init as maximum possible */
76
 
77
        /*
78
         * Do the test
79
         */
80
        printf("Starting the l4_getid cycle counter test.\n");
81
        for (int i = 0; i < PERFTEST_GETID_COUNT; i++) {
82
                perfmon_reset_start_cyccnt();
83
                l4_getid(&ids);
84
                perfmon_record_cycles(&l4_getid_cycles,
85
                                      "l4_getid");
86
        }
87
 
88
        /*
89
         * Calculate average
90
         */
91
        l4_getid_cycles.avg = l4_getid_cycles.total / l4_getid_cycles.ops;
92
 
93
        /*
94
         * Print results
95
         */
96
        printf("PERFMON: %s took %llu min, %llu max, %llu avg, "
97
               "%llu total microseconds in %llu ops.\n",
98
               "l4_getid()",
99
               l4_getid_cycles.min * USEC_MULTIPLIER,
100
               l4_getid_cycles.max * USEC_MULTIPLIER,
101
               l4_getid_cycles.avg * USEC_MULTIPLIER,
102
               l4_getid_cycles.total * USEC_MULTIPLIER,
103
               l4_getid_cycles.ops);
104
}

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.