Added HP/DHP internal stats to test
[libcds.git] / test / include / cds_test / stat_dhp_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_DHP_OUT_H
32 #define CDSTEST_STAT_DHP_OUT_H
33
34 #include <cds/gc/dhp.h>
35 #include <ostream>
36
37 namespace cds_test {
38
39     static inline property_stream& operator <<( property_stream& o, cds::gc::DHP::stat const& s )
40     {
41 #ifdef CDS_ENABLE_HPSTAT
42 #   define CDS_HPSTAT_OUT( stat, fld ) std::make_pair( "dhp_" + 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             << CDS_HPSTAT_OUT( s, hp_block_count )
52             << CDS_HPSTAT_OUT( s, retired_block_count )
53             << CDS_HPSTAT_OUT( s, hp_extend_count )
54             << CDS_HPSTAT_OUT( s, retired_extend_count );
55 #   undef CDS_HPSTAT_OUT
56 #else
57         return o;
58 #endif
59     }
60
61 } // namespace cds_test
62
63 static inline std::ostream& operator <<( std::ostream& o, cds::gc::DHP::stat const& s )
64 {
65 #ifdef CDS_ENABLE_HPSTAT
66 #   define CDS_HPSTAT_OUT( stat, fld ) "\t" << #fld << "=" << stat.fld << "\n"
67     return o
68         << "DHP post-mortem statistics:\n"
69         << CDS_HPSTAT_OUT( s, guard_allocated )
70         << CDS_HPSTAT_OUT( s, guard_freed )
71         << CDS_HPSTAT_OUT( s, retired_count )
72         << CDS_HPSTAT_OUT( s, free_count )
73         << CDS_HPSTAT_OUT( s, scan_count )
74         << CDS_HPSTAT_OUT( s, help_scan_count )
75         << CDS_HPSTAT_OUT( s, thread_rec_count )
76         << CDS_HPSTAT_OUT( s, hp_block_count )
77         << CDS_HPSTAT_OUT( s, retired_block_count )
78         << CDS_HPSTAT_OUT( s, hp_extend_count )
79         << CDS_HPSTAT_OUT( s, retired_extend_count );
80 #   undef CDS_HPSTAT_OUT
81 #else
82     return o;
83 #endif
84 }
85
86
87 #endif // #ifndef CDSTEST_STAT_DHP_OUT_H