Split stress-queue test
[libcds.git] / test / include / cds_test / stat_hp_out.h
1 /*
2     This file is a part of libcds - Concurrent Data Structures library
3
4     (C) Copyright Maxim Khizhinsky (libcds.dev@gmail.com) 2006-2017
5
6     Source code repo: http://github.com/khizmax/libcds/
7     Download: http://sourceforge.net/projects/libcds/files/
8
9     Redistribution and use in source and binary forms, with or without
10     modification, are permitted provided that the following conditions are met:
11
12     * Redistributions of source code must retain the above copyright notice, this
13       list of conditions and the following disclaimer.
14
15     * Redistributions in binary form must reproduce the above copyright notice,
16       this list of conditions and the following disclaimer in the documentation
17       and/or other materials provided with the distribution.
18
19     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20     AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21     IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22     DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23     FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24     DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25     SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27     OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28     OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30
31 #ifndef CDSTEST_STAT_HP_OUT_H
32 #define CDSTEST_STAT_HP_OUT_H
33
34 #include <cds/gc/hp.h>
35 #include <ostream>
36
37 namespace cds_test {
38
39     static inline property_stream& operator <<( property_stream& o, cds::gc::HP::stat const& s )
40     {
41 #ifdef CDS_ENABLE_HPSTAT
42 #   define CDS_HPSTAT_OUT( stat, fld ) std::make_pair( "hp_" + property_stream::stat_prefix() + "." #fld, stat.fld )
43         return o
44             << CDS_HPSTAT_OUT( s, guard_allocated )
45             << CDS_HPSTAT_OUT( s, guard_freed )
46             << CDS_HPSTAT_OUT( s, retired_count )
47             << CDS_HPSTAT_OUT( s, free_count )
48             << CDS_HPSTAT_OUT( s, scan_count )
49             << CDS_HPSTAT_OUT( s, help_scan_count )
50             << CDS_HPSTAT_OUT( s, thread_rec_count );
51 #   undef CDS_HPSTAT_OUT
52 #else
53         return o;
54 #endif
55     }
56
57 } // namespace cds_test
58
59 static inline std::ostream& operator <<( std::ostream& o, cds::gc::HP::stat const& s )
60 {
61 #ifdef CDS_ENABLE_HPSTAT
62 #   define CDS_HPSTAT_OUT( stat, fld ) "\t" << #fld << "=" << stat.fld << "\n"
63     return o
64         << "HP post-mortem statistics:\n"
65         << CDS_HPSTAT_OUT( s, guard_allocated )
66         << CDS_HPSTAT_OUT( s, guard_freed )
67         << CDS_HPSTAT_OUT( s, retired_count )
68         << CDS_HPSTAT_OUT( s, free_count )
69         << CDS_HPSTAT_OUT( s, scan_count )
70         << CDS_HPSTAT_OUT( s, help_scan_count )
71         << CDS_HPSTAT_OUT( s, thread_rec_count );
72 #   undef CDS_HPSTAT_OUT
73 #else
74     return o;
75 #endif
76 }
77
78 #endif // #ifndef CDSTEST_STAT_HP_OUT_H