X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f From: Alex Vinokur Newsgroups: comp.software.measurement,comp.lang.c++,comp.os.msdos.djgpp,comp.games.development.programming.misc Subject: C/C++ Program Perfometer Date: Tue, 05 Mar 2002 16:01:00 +0200 Lines: 970 Message-ID: <3C84CF9B.AA99EFA8@bigfoot.com> References: <3C848503 DOT AB2A4938 AT bigfoot DOT com> NNTP-Posting-Host: 62.90.123.5 Mime-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Transfer-Encoding: 7bit X-Trace: fu-berlin.de 1015336803 11643643 62.90.123.5 (16 [79865]) X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com A program that enables to get C/C++ program performance for any metrics has been written. |-----------------------------------------------| |---> 1. Fragments from README.txt file etc <---| |-----------------------------------------------| ============================================ --------- C/C++ Program Perfometer --------- ============================================ ===================================== AVAILABILITY ----------------------------------- ### Web page ### http://alexvn.freeservers.com/s1/perfometer.html Content. 1. Algorithm 2. Classes 3. Program Files 4. Compiling 5. Running (Log Files) 6. Download ----------------------------------- ### Download ### http://alexvn.freeservers.com/s1/perfometer.zip Also : ### Sources (in alt.sources) ### http://groups.google.com/groups?hl=en&th=12f55903796dc3fa Files: 0. README.txt --- Program Files --- 1. macro.h Various Macro 2. common.h Common Function etc 3. user.h User-Specialized Function Declaration 4. pfmeter.h Definition of Common Classes 5. pfmeter2.h Implementation of Common Template Classes 6. pfmeter.c Implementation of Common (Non-Template) Classes 7. adapt.h Definition of User-Related Classes 8. adapt.c Implementation of User-Related Classes 9. demo.h Declaration of Measured/Compared Functions 10. demo.c Implementation of Measured/Compared functions 11. demo2.c Implementation of Measured/Compared functions 12. main.c Main Program --- Log Files --- 16. log1_h.txt Running results (invocation : a.exe -h) 17. log2_s.txt Running results (invocation : a.exe -s) 18. log3_d.txt Running results (invocation : a.exe -d) 19. log4_m.txt Running results (invocation : a.exe -m) 20. log5.txt Running results (invocation : a.exe) 21. log6_v.txt Running results (invocation : a.exe -i 70000 -f 0.23 -e 11 -p 2500) --- Info File --- 22. perfometer.html ===================================== ENVIRONMENT ### System & Compiler ### Windows98 gpp : GNU C++ version 2.95.3 20010315/djgpp (release) (djgpp) compiled by GNU C version 2.95.3 20010315/djgpp (release). |-----------------------------------------------| |-------------> 2. Sample Output <--------------| |-----------------------------------------------| #========================= # C/C++ Program Perfometer # Alex Vinokur # http://up.to/alexvn #------------------------- # START # Mon Mar 4 14:22:14 2002 #========================= ---> YOUR COMMAND LINE : a.exe -m ====================================================================== * ENVIRONMENT VARIABLES (Actual Values) * ------------------------------------- * Measurement Report : Disable * Tracing Report : Disable * Total Iteration : 90000 * Total Tests : 15 * Scale per Calls Value : 10000 * Confidence Threshold : 0.17 ====================================================================== ========================================== %%======================================== %% %% Total Measured Resources : 3 %% %% ---------- Resource#1 ---------- %% Resource Name : user time used %% Resource Cost Unit : uclock %% Resource State Unit : uclock %% ---> Total measured functions : 19 %% %% ---------- Resource#2 ---------- %% Resource Name : user time used (via rusage) %% Resource Cost Unit : msec %% Resource State Unit : timeval %% ---> Total measured functions : 2 %% %% ---------- Resource#3 ---------- %% Resource Name : pseudo resource %% Resource Cost Unit : cost-BBB-unit %% Resource State Unit : state-AAA-unit %% ---> Total measured functions : 2 %% %% %%======================================== ========================================== |||||||||||||||||||||||||||||||||||||||| || || --------------- || Resource#1 of 3 || --------------- || Resource Name : user time used || Resource Cost Unit : uclock || Resource State Unit : uclock || --------------- || || ****************************** || *** Performance Comparison *** || ****************************** || || |||||||||||||||||||||||||||||||||||||||| #================================================ # Comparison Group#1 of 4 : delete-new-string etc #------------------------------------------------ # Resource Name : user time used # Resource Cost Unit : uclock # Resource State Unit : uclock #================================================ : ---------------------------------------------------------------------------------------- : demo_01 : demo.c #98 : do nothing -> 87 : demo_02 : demo.c #108 : delete new string of size 40 -> 16407 : demo_03 : demo.c #118 : delete new string of size 4 -> 12482 : demo_04 : demo.c #128 : delete new string of size 4 (10 times) -> 127645 : demo_05 : demo.c #141 : delete new string of size 4 (20 times) -> 259604 : ---------------------------------------------------------------------------------------- #================================================= # Comparison Group#2 of 4 : delete-new-string only #------------------------------------------------- # Resource Name : user time used # Resource Cost Unit : uclock # Resource State Unit : uclock #================================================= : ---------------------------------------------------------------------------------------- : demo_05 : demo.c #141 : delete new string of size 4 (20 times) -> 259604 : demo_06 : demo.c #155 : delete new string of size 6 -> 14638 : demo_07 : demo.c #183 : delete new string of size 9 -> 14117 : ---------------------------------------------------------------------------------------- #======================================================= # Comparison Group#3 of 4 : ostrstream vs. ostringstream #------------------------------------------------------- # Resource Name : user time used # Resource Cost Unit : uclock # Resource State Unit : uclock #======================================================= : ---------------------------------------------------------------------------------------- : write_to_stream : demo2.c #142 : to-ostringstream-5 -> 106443 : write_to_stream : demo2.c #152 : to-ostringstream-25 -> 462756 : write_to_stream : demo2.c #162 : to-ostrstream5 -> 36716 : write_to_stream : demo2.c #172 : to-ostrstream25 -> 41662 : ---------------------------------------------------------------------------------------- #================================================= # Comparison Group#4 of 4 : strlen vs. string-size #------------------------------------------------- # Resource Name : user time used # Resource Cost Unit : uclock # Resource State Unit : uclock #================================================= : ---------------------------------------------------------------------------------------- : get_string_size : demo2.c #75 : string-size-5 -> 307 : get_string_size : demo2.c #84 : string-size-25 -> 309 : get_string_size : demo2.c #93 : string-size-125 -> 310 : get_string_size : demo2.c #101 : strlen-5 -> 598 : get_string_size : demo2.c #109 : strlen-25 -> 1790 : get_string_size : demo2.c #117 : strlen-125 -> 9512 : ---------------------------------------------------------------------------------------- |||||||||||||||||||||||||||||||||||||||| || || --------------- || Resource#2 of 3 || --------------- || Resource Name : user time used (via rusage) || Resource Cost Unit : msec || Resource State Unit : timeval || --------------- || || ****************************** || *** Performance Comparison *** || ****************************** || || |||||||||||||||||||||||||||||||||||||||| #================================================ # Comparison Group#1 of 4 : delete-new-string etc #------------------------------------------------ # Resource Name : user time used (via rusage) # Resource Cost Unit : msec # Resource State Unit : timeval #================================================ : ---------------------------------------------------------------------------------------- : No functions to be compared : ---------------------------------------------------------------------------------------- #================================================= # Comparison Group#2 of 4 : delete-new-string only #------------------------------------------------- # Resource Name : user time used (via rusage) # Resource Cost Unit : msec # Resource State Unit : timeval #================================================= : ---------------------------------------------------------------------------------------- : demo_06 : demo.c #162 : delete new string of size 6 -> 10 : demo_08 : demo.c #196 : delete new string of size 6 -> 13.8788 : ---------------------------------------------------------------------------------------- #======================================================= # Comparison Group#3 of 4 : ostrstream vs. ostringstream #------------------------------------------------------- # Resource Name : user time used (via rusage) # Resource Cost Unit : msec # Resource State Unit : timeval #======================================================= : ---------------------------------------------------------------------------------------- : No functions to be compared : ---------------------------------------------------------------------------------------- #================================================= # Comparison Group#4 of 4 : strlen vs. string-size #------------------------------------------------- # Resource Name : user time used (via rusage) # Resource Cost Unit : msec # Resource State Unit : timeval #================================================= : ---------------------------------------------------------------------------------------- : No functions to be compared : ---------------------------------------------------------------------------------------- |||||||||||||||||||||||||||||||||||||||| || || --------------- || Resource#3 of 3 || --------------- || Resource Name : pseudo resource || Resource Cost Unit : cost-BBB-unit || Resource State Unit : state-AAA-unit || --------------- || || ****************************** || *** Performance Comparison *** || ****************************** || || |||||||||||||||||||||||||||||||||||||||| #================================================ # Comparison Group#1 of 4 : delete-new-string etc #------------------------------------------------ # Resource Name : pseudo resource # Resource Cost Unit : cost-BBB-unit # Resource State Unit : state-AAA-unit #================================================ : ---------------------------------------------------------------------------------------- : No functions to be compared : ---------------------------------------------------------------------------------------- #================================================= # Comparison Group#2 of 4 : delete-new-string only #------------------------------------------------- # Resource Name : pseudo resource # Resource Cost Unit : cost-BBB-unit # Resource State Unit : state-AAA-unit #================================================= : ---------------------------------------------------------------------------------------- : demo_06 : demo.c #170 : delete new string of size 6 -> BBB-174005461 : demo_09 : demo.c #208 : delete new string of size 6 -> BBB-82659391 : ---------------------------------------------------------------------------------------- #======================================================= # Comparison Group#3 of 4 : ostrstream vs. ostringstream #------------------------------------------------------- # Resource Name : pseudo resource # Resource Cost Unit : cost-BBB-unit # Resource State Unit : state-AAA-unit #======================================================= : ---------------------------------------------------------------------------------------- : No functions to be compared : ---------------------------------------------------------------------------------------- #================================================= # Comparison Group#4 of 4 : strlen vs. string-size #------------------------------------------------- # Resource Name : pseudo resource # Resource Cost Unit : cost-BBB-unit # Resource State Unit : state-AAA-unit #================================================= : ---------------------------------------------------------------------------------------- : No functions to be compared : ---------------------------------------------------------------------------------------- #========================= # C/C++ Program Perfometer # Alex Vinokur # http://up.to/alexvn #------------------------- # FINISH # Mon Mar 4 14:24:43 2002 #========================= |-----------------------------------------------| |-> 3. Sample Code (related to Sample Output) <-| |-----------------------------------------------| // ######################################################### // === File #9 of 12 : demo.h ============================== // ------------------- C++ code : BEGIN -------------------- // ============================================================== // // Copyright (c) 2002 by Alex Vinokur. This work and all works // derived from it may be copied and modified without any // restrictions other than that a copy of this copyright notice // must be included in any copy of this work or any derived work. // // ============================================================== // ######################################################### // ## mailto:alexvn AT bigfoot DOT com, mailto:alexv AT hitechclub DOT com // ## http://up.to/alexv, http://go.to/alexv_math // ######################################################### // ============================================================== // ############################################################## // // SOFTWARE : C/C++ Program Perfometer // FILE : demo.h // // DESCRIPTION : // Declaration of measured/compared functions // // ---- ---------- // Created 2002-03-04 // ---- ---------- // // ############################################################## /////////////// #ifndef _DEMO_H #define _DEMO_H /////////////// // =========================== #include "adapt.h" // --------------------------- void demo_01 (void); void demo_02 (void); void demo_03 (void); void demo_04 (void); void demo_05 (void); void demo_06 (void); void demo_07 (void); void demo_08 (void); void demo_09 (void); void demo_10 (void); void demo_11 (void); void get_string_size (void); void write_to_stream (void); // ########################################### #endif // ########################################### // ------------------- C++ code : END ---------------------- // === File #9 of 12 : demo.h ============================== // ######################################################### // === File #10 of 12 : demo.c ============================= // ------------------- C++ code : BEGIN -------------------- // ============================================================== // // Copyright (c) 2002 by Alex Vinokur. This work and all works // derived from it may be copied and modified without any // restrictions other than that a copy of this copyright notice // must be included in any copy of this work or any derived work. // // ============================================================== // ######################################################### // ## mailto:alexvn AT bigfoot DOT com, mailto:alexv AT hitechclub DOT com // ## http://up.to/alexv, http://go.to/alexv_math // ######################################################### // ============================================================== // ############################################################## // // SOFTWARE : C/C++ Program Perfometer // FILE : demo.c // // DESCRIPTION : // Implementation of measured/compared functions // // ---- ---------- // Created 2002-03-04 // ---- ---------- // // ############################################################## // ============== #include "demo.h" // ============== // ######################################### // # // # Function Implementation // # Prototypes are in file user.h // # // ######################################### // ============================= void SetEnvIt () { SetTotalTests (15); SetScaleAndTotalIterations (10000, 90000); SetDiscardingThreshold(0.17); SetDetailedMeasurementReportFlag(true); SetMeasurementReportFlag(true); //SetTracingReportFlag(true); } // ============================= void MeasureIt () { MeasureFunc (demo_10); MeasureFunc (demo_11); } // ============================= void CompareIt () { CompareFunc ("delete-new-string etc", demo_01); CompareFunc ("delete-new-string etc", demo_02); CompareFunc ("delete-new-string etc", demo_03); CompareFunc ("delete-new-string etc", demo_04); CompareFunc ("delete-new-string etc", demo_05); CompareFunc ("delete-new-string only", demo_05); CompareFunc ("delete-new-string only", demo_06); CompareFunc ("delete-new-string only", demo_07); CompareFunc ("delete-new-string only", demo_08); CompareFunc ("delete-new-string only", demo_09); CompareFunc ("strlen vs. string-size", get_string_size); CompareFunc ("ostrstream vs. ostringstream", write_to_stream); } // CompareIt // ######################################### // # // # Functions To Be Measured (Compared) // # Prototypes are in file demo.h // # // ######################################### // ============================= void demo_01 (void) { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, "do nothing") { } } // demo_01 // ============================= void demo_02 (void) { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, "delete new string of size 40") { delete new std::string("1234567890123456789012345678901234567890"); } } // demo_02 // ============================= void demo_03 (void) { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, "delete new string of size 4") { delete new std::string("ABCD"); } } // demo_03 // ============================= void demo_04 (void) { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, "delete new string of size 4 (10 times)") { for (int i = 0; i < 10; i++) { delete new std::string("ABCD"); } } } // demo_04 // ============================= void demo_05 (void) { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, "delete new string of size 4 (20 times)") { for (int i = 0; i < 20; i++) { delete new std::string("ABCD"); } } } // demo_05 // ============================= void demo_06 (void) { { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, "delete new string of size 6") { delete new std::string("ABCDEF"); } } { TURN_ON (timeval, double, RESOURCE_user_time_used, "delete new string of size 6") { delete new std::string("ABCDEF"); } } { TURN_ON (AAA, BBB, RESOURCE_pseudo, "delete new string of size 6") { delete new std::string("ABCDEF"); } } } // demo_06 // ============================= void demo_07 (void) { { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, "delete new string of size 9") { delete new std::string("ABCDEF123"); } } } // demo_07 // ============================= void demo_08 (void) { { TURN_ON (timeval, double, RESOURCE_user_time_used, "delete new string of size 6") { delete new std::string("ABCDEF123"); } } } // demo_08 // ============================= void demo_09 (void) { { TURN_ON (AAA, BBB, RESOURCE_pseudo, "delete new string of size 6") { delete new std::string("ABCDEF123"); } } } // demo_09 // ============================= void demo_10 (void) { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, "delete new string of size 5") { delete new std::string("ABCDE"); } } // demo_10 // ============================= void demo_11 (void) { char str[] = "ABCD"; TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, "strlen-4") { strlen(str); } } // demo_11 // ########################################### // ------------------- C++ code : END ---------------------- // === File #10 of 12 : demo.c ============================= // ######################################################### // === File #11 of 12 : demo2.c ============================ // ------------------- C++ code : BEGIN -------------------- // ============================================================== // // Copyright (c) 2002 by Alex Vinokur. This work and all works // derived from it may be copied and modified without any // restrictions other than that a copy of this copyright notice // must be included in any copy of this work or any derived work. // // ============================================================== // ######################################################### // ## mailto:alexvn AT bigfoot DOT com, mailto:alexv AT hitechclub DOT com // ## http://up.to/alexv, http://go.to/alexv_math // ######################################################### // ============================================================== // ############################################################## // // SOFTWARE : C/C++ Program Perfometer // FILE : demo2.c // // DESCRIPTION : // Implementation of measured/compared functions // // ---- ---------- // Created 2002-03-04 // ---- ---------- // // ############################################################## // ============== #include "demo.h" // ============== // ######################################### // # // # Functions To Be Measured (Compared) // # Prototypes are in file demo.h // # // ######################################### #define STRING_SIZE_1 5 #define STRING_SIZE_2 25 #define STRING_SIZE_3 125 // ---------------------------- void get_string_size (void) { string sstr1 (STRING_SIZE_1, 'a'); string sstr2 (STRING_SIZE_2, 'b'); string sstr3 (STRING_SIZE_3, 'c'); char cstr1 [STRING_SIZE_1 + 1]; char cstr2 [STRING_SIZE_2 + 1]; char cstr3 [STRING_SIZE_3 + 1]; strcpy (cstr1, sstr1.c_str()); strcpy (cstr2, sstr2.c_str()); strcpy (cstr3, sstr3.c_str()); const string text_sstr1 = "string-size-" + to_string (STRING_SIZE_1); const string text_sstr2 = "string-size-" + to_string (STRING_SIZE_2); const string text_sstr3 = "string-size-" + to_string (STRING_SIZE_3); const string text_cstr1 = "strlen-" + to_string (STRING_SIZE_1); const string text_cstr2 = "strlen-" + to_string (STRING_SIZE_2); const string text_cstr3 = "strlen-" + to_string (STRING_SIZE_3); // --------------------------------------------------------- { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, text_sstr1) { sstr1.size(); } } // --------------------------------------------------------- { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, text_sstr2) { sstr2.size(); } } // --------------------------------------------------------- { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, text_sstr3) { sstr3.size(); } } // --------------------------------------------------------- { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, text_cstr1) { strlen (cstr1); } } // --------------------------------------------------------- { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, text_cstr2) { strlen (cstr2); } } // --------------------------------------------------------- { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, text_cstr3) { strlen (cstr3); } } } // get_strlen // ---------------------------- void write_to_stream (void) { string sstr1 (STRING_SIZE_1, 'a'); string sstr2 (STRING_SIZE_2, 'b'); const string text_osstr1 = "to-ostringstream-" + to_string (STRING_SIZE_1); const string text_osstr2 = "to-ostringstream-" + to_string (STRING_SIZE_2); const string text_ostr1 = "to-ostrstream" + to_string (STRING_SIZE_1); const string text_ostr2 = "to-ostrstream" + to_string (STRING_SIZE_2); // --------------------------------------------------------- { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, text_osstr1) { ostringstream osstr; osstr << sstr1; } } // --------------------------------------------------------- { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, text_osstr2) { ostringstream osstr; osstr << sstr2; } } // --------------------------------------------------------- { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, text_ostr1) { ostrstream ostr; ostr << sstr1; ostr.rdbuf()->freeze (0); } } // --------------------------------------------------------- { TURN_ON (uclock_t, uclock_t, RESOURCE_user_time_used, text_ostr2) { ostrstream ostr; ostr << sstr2; ostr.rdbuf()->freeze (0); } } } // write_to_stream // ------------------- C++ code : END ---------------------- // === File #11 of 12 : demo2.c ============================ -- =========================== Alex Vinokur mailto:alexvn AT bigfoot DOT com mailto:alexvnw AT yahoo DOT com http://up.to/alexvn http://go.to/alexv_math ===========================