source: tests/zombies/linked-list-perf/experiment.koad @ 50e04cc

Last change on this file since 50e04cc was 55b060d, checked in by Peter A. Buhr <pabuhr@…>, 16 months ago

rename directories containers to collections

  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2
3$cfa is the result of building this configuration:
4../cfa-cc/configure --with-target-hosts=host:nodebug CXX=g++-
5
6~/u++ is my own download of uC++ 7.0.0
7
8$cfa -xc experiment.koad -DIMPL_CFA_MIKE_OLD -o perfexp-cfa-mike-old -nodebug -O2
9$cfa -xc experiment.koad -DIMPL_CFA_MIKE_NEW -o perfexp-cfa-mike-new -nodebug -O2
10$cfa -xc experiment.koad -DIMPL_CFA_MIKE_POC -o perfexp-cfa-mike-poc -nodebug -O2
11$cfa -xc experiment.koad -DIMPL_CFA_COLBY -o perfexp-cfa-colby -nodebug -O2
12$cfa -xc experiment.koad -DIMPL_CFA_THIERRY_SUB -o perfexp-cfa-thierry-sub -nodebug -O2
13g++ -xc++ experiment.koad -DIMPL_STL -DNDEBUG -o perfexp-stlgpp -O2
14~/u++/u++-7.0.0/bin/u++ experiment.cpp -DIMPL_UPP -DNDEBUG -o perfexp-uppupp -O2
15
16                        O2      O2-ltd  O3-ltd
17perfexp-cfa-mike-old    2.50    2.55
18perfexp-cfa-mike-new            2.18    2.15
19perfexp-cfa-mike-poc    1.74    1.71
20perfexp-cfa-colby       2.90    2.84    3.09
21perfexp-cfa-thierry-sub 1.85
22perfexp-stlgpp          4.57    4.72
23perfexp-uppupp          2.09    1.94    1.91
24
25O2-ltd is
26 -fno-tree-pre -fno-gcse
27 (An earlier draft of mike-new didn't work without disabling those optimizations; we probably don't care about that anymore.)
28
29*/
30
31#include <time.h>
32#include <stdio.h>
33
34#if defined IMPL_STL
35
36        #include <list>
37        struct S {
38                volatile int f[64];
39        };
40
41#elif defined IMPL_UPP
42
43        #include <uC++.h>
44        #include <uSequence.h>
45        struct S : public uSeqable {
46                volatile int f[64];
47        };
48
49#elif defined IMPL_CFA_MIKE_OLD
50
51        #include "mike-old.hfa"
52        struct S {
53                int f[64]; // FIXME: make "is volatile" consistent; given bug #TBD
54                DLISTED_MGD_IMPL_IN(S)
55        };
56        DLISTED_MGD_IMPL_OUT(S)
57
58#elif defined IMPL_CFA_MIKE_POC
59
60        #include "mike-proto-list.hfa"
61        struct S {
62                int f[64]; // FIXME: make "is volatile" consistent; given bug #TBD
63                inline dlink(S);
64        };
65        P9_EMBEDDED( S, dlink(S) )
66
67#elif defined IMPL_CFA_MIKE_NEW
68
69        #include <collections/list.hfa>
70        struct S {
71                int f[64]; // FIXME: make "is volatile" consistent; given bug #TBD
72                inline dlink(S);
73        };
74        P9_EMBEDDED( S, dlink(S) )
75
76#elif defined IMPL_CFA_COLBY
77
78        #include <bits/sequence.hfa>
79        struct S {
80                inline Seqable;
81                int f[64]; // FIXME: make "is volatile" consistent; given bug #TBD
82        };
83        static inline S *& Back( S * n ) {
84                return (S *)Back( (Seqable *)n );
85        }
86        static inline S *& Next( S * n ) {
87                return (S *)Next( (Colable *)n );
88        }
89
90#elif defined IMPL_CFA_THIERRY_SUB
91
92        #include "thierry-subqueue-old-rip.hfa"
93        typedef  $thread S;
94
95
96#else
97        #error bad impl
98#endif
99
100
101#define Repeat( op ) for ( volatile unsigned int i = 0; i < NoOfNodes; i += 1 ) { op; }
102
103int main() {
104        enum { NoOfNodes = 1000, Times = 100000 }; // Times supposed to be 100000
105        S s[NoOfNodes];
106        clock_t start, end;
107        const char * impl = 0;
108
109    #define STATS
110    #define REPORT do { \
111        double elapsed = ((double) (end - start)) / CLOCKS_PER_SEC; \
112        printf("%s %f sec\n", impl, elapsed); \
113        STATS \
114    } while(0);
115
116    #if defined IMPL_STL
117    do {
118        std::list<S *> lst;
119        start = clock();
120        for ( volatile unsigned int t = 0; t < Times; t += 1 ) {
121                Repeat( lst.push_back( &s[i] ) );
122                Repeat( lst.pop_front() );
123        }
124        end = clock();
125        impl = "STL list, pointer";
126        REPORT
127    } while (0);
128    #elif defined IMPL_UPP
129    do {
130        uSequence<S> lst;
131        start = clock();
132        for ( volatile unsigned int t = 0; t < Times; t += 1 ) {
133                Repeat( lst.addTail( &s[i] ) );
134                Repeat( lst.dropHead() );
135        }
136        end = clock();
137        impl = "u++ intrusive list";
138        REPORT
139    } while (0);
140    #elif defined IMPL_CFA_MIKE_OLD
141    do {
142        dlist(S, S) lst;
143        start = clock();
144        for ( volatile unsigned int t = 0; t < Times; t += 1 ) {
145                Repeat( insert_last( lst, s[i] ) );
146                Repeat( remove( lst`first ) );
147        }
148        end = clock();
149        impl = "cfa mike-old intrusive list";
150        REPORT
151    } while (0);
152    #elif defined IMPL_CFA_MIKE_POC
153    do {
154        dlist(S) lst;
155        start = clock();
156        for ( volatile unsigned int t = 0; t < Times; t += 1 ) {
157                Repeat( insert_last( lst, s[i] ) );
158                Repeat( remove_first( lst ) );
159        }
160        end = clock();
161        impl = "cfa mike-poc intrusive list";
162        REPORT
163    } while (0);
164    #elif defined IMPL_CFA_MIKE_NEW
165    do {
166        dlist(S) lst;
167        start = clock();
168        for ( volatile unsigned int t = 0; t < Times; t += 1 ) {
169                Repeat( insert_last( lst, s[i] ) );
170                Repeat( remove( lst`first ) );
171        }
172        end = clock();
173        impl = "cfa mike-new intrusive list";
174        REPORT
175    } while (0);
176    #elif defined IMPL_CFA_COLBY
177    do {
178        Sequence(S) lst;
179        start = clock();
180        for ( volatile unsigned int t = 0; t < Times; t += 1 ) {
181                Repeat( addHead( lst, s[i] ) );
182                Repeat( dropTail( lst ) );
183        }
184        end = clock();
185        impl = "cfa colby intrusive list";
186        REPORT
187    } while (0);
188
189    #elif defined IMPL_CFA_THIERRY_SUB
190    do {
191        __intrusive_lane_t lst;
192        start = clock();
193        for ( volatile unsigned int t = 0; t < Times; t += 1 ) {
194                Repeat( push( lst, &s[i] ) );
195                Repeat( pop( lst ) );
196        }
197        end = clock();
198        impl = "cfa thierry subqueue intrusive list";
199        REPORT
200    } while (0);
201
202    #endif
203}
Note: See TracBrowser for help on using the repository browser.