File indexing completed on 2026-04-09 07:49:20
0001 #include "sprof.h"
0002
0003 void test_uninitialized()
0004 {
0005 sprof u ;
0006 std::cout << " sprof u : " << sprof::Desc_(u) << std::endl ;
0007
0008 sprof* d0 = new sprof ;
0009 std::cout << " new sprof : " << sprof::Desc_(*d0) << std::endl ;
0010
0011 sprof* d1 = new sprof() ;
0012 std::cout << " new sprof() :" << sprof::Desc_(*d1) << std::endl ;
0013
0014 }
0015
0016
0017 void test_procedural()
0018 {
0019 sprof p = {} ;
0020 std::cout << sprof::Desc_(p) << std::endl ;
0021
0022 for(int i=0 ; i < 100 ; i++)
0023 {
0024 sprof::Stamp(p);
0025
0026 std::string str = sprof::Desc_(p) ;
0027 bool llpt = sprof::LooksLikeProfileTriplet(str.c_str()) ;
0028 std::cout << str << " llpt " << ( llpt ? "YES" : "NO " ) << std::endl ;
0029 }
0030 }
0031
0032
0033 struct sprof_test
0034 {
0035 sprof p0 ;
0036 sprof p1 ;
0037
0038 void dump(const char* msg="") const ;
0039
0040 sprof_test();
0041 ~sprof_test();
0042 };
0043
0044 void sprof_test::dump(const char* msg) const
0045 {
0046 std::cout
0047 << msg
0048 << std::endl
0049 << "p0 " << sprof::Desc_(p0)
0050 << std::endl
0051 << "p1 " << sprof::Desc_(p1)
0052 << std::endl
0053 ;
0054 }
0055
0056
0057 sprof_test::sprof_test()
0058 :
0059 p0(),
0060 p1()
0061 {
0062 sprof::Stamp(p0);
0063 dump("ctor");
0064 sstamp::sleep(1);
0065 }
0066
0067 sprof_test::~sprof_test()
0068 {
0069 sprof::Stamp(p1);
0070 dump("dtor");
0071 }
0072
0073
0074 void test_ctor_dtor()
0075 {
0076 sprof_test t ;
0077 }
0078 void test_Serialize_Import()
0079 {
0080 sprof p0 ;
0081 sprof::Stamp(p0);
0082
0083
0084
0085 std::string data = sprof::Serialize(p0);
0086 std::cout << data << std::endl ;
0087
0088 sprof p1 ;
0089 sprof::Import( p1, data.c_str() ) ;
0090
0091 std::cout << "p0:" << sprof::Desc_(p0) << std::endl ;
0092 std::cout << "p1:" << sprof::Desc_(p1) << std::endl ;
0093
0094 assert( sprof::Equal(p0, p1) );
0095 }
0096
0097
0098 int main(int argc, char** argv)
0099 {
0100
0101
0102
0103
0104
0105 test_Serialize_Import();
0106
0107 return 0 ;
0108 }