Names Default To Here( 1 ); Clear Log(); Clear Globals(); Clear Symbols(); If( Host is( "Windows" ), , Throw() ); // (jmp for windows only) // ------------------------------------------------------------------- Include( "j2f_Include.jsl" ); // Contains WINAPI & j2fAPI definitions // june 2020 version (c) 2020 Franco Anzani - SixSigmaIn Team snc Include( "j2f_Demo_msg.jsl" ); // Contains this demo txt messages Title = Concat( " availble in j2Friend :", _$crlf, _$crlf, "private : processed by a single Client only,", _$crlf, "public : processed by all active Clients,", _$crlf, "common : as public for active Clients with same class only.", _$crlf, _$crlf, "This code (video) tests (shows) the difference of a private vs a public message." ); // iExcel = 1; // first COM.App.Client > test a fast COM.App // do not change iLed_1 = 2; // first Custom.Client // do not change iLed_2 = 3; // second Custom.Client ( Same Class of iLed_1 Client ) // do not change iMinitab = 4; // second COM.App.Client > test a slow COM.App and a different Client Class // do not change // // Stress Test Options --------------------------------------------- Use_Two_ComApps = 1; // 0 no use it or 1 to use it Test_max_ISize = 100; // 500; // loop size Test_show_MsgBox = 1; // show msgbox Test_show_res = 1; // show info to log during test Test_COM_App_hidden = 0; // hide COM.Apps or not Test_Add_Clients = 0; // additional Custom App Clients try 0, 1 or more //---------------------------------------------------------------------- ID_MSG_public = 0; ID_MSG_public = iLed_1; // <----- rem this line to restore UnitTest msg to this Client as private // // // - Start Host --------------------------------------------- If( Init_message( Title ) == 2, Stop() ); meHost = Create_Me(); If( meHost == _%false, Throw() ); // set jsl (jmp) as host , exit on error // // - Create random data --------------------------------------------- Col_Data = J( Test_max_ISize, 1, Random Integer( 0, 2147483647 ) ); rnd_dt = New Table( "Temp", New Column( "J_Data", Numeric, Continuous, Set Values( Col_Data ) ), New Column( "J_Mod_8", Numeric, Continuous, Formula( Modulo( :Name( "J_Data" ), 8 ) ) ) ); // // - Start Clients ---------------------------- Test_Clients = 3 + Use_Two_ComApps; j2f_clients = Test_Clients + Test_Add_Clients; i_Els = Char( Test_max_ISize ); If( Test_COM_App_hidden, c_mode = _$as_hide, c_mode = _$as_view ); ComApp = "excel.application"; If( test_show_MsgBox, MessageBox_fn( Concat( "The table with ", i_Els, " Random Data is ready. Now Press Ok to start a COM.App as Client (", ComApp, " ", c_mode, ")" ), _%bt_Ok ) ); New_Client( meHost, iExcel, "mte_CRT.exe", ComApp, c_mode ); // If( test_show_MsgBox, MessageBox_fn( "Press Ok to start two Custom Apps as Clients", _%bt_Ok ) ); New_Client( meHost, iLed_1, "mte_led.exe", _$as_custom, _$as_view ); New_Client( meHost, iLed_2, "mte_led.exe", _$as_custom, _$as_view ); // If( Use_Two_ComApps, ComApp = "mtb.application"; If( test_show_MsgBox, MessageBox_fn( Concat( "Press Ok to start a second COM.App as Client (", ComApp, " ", c_mode, ")" ), _%bt_Ok ) ); New_Client( meHost, iMinitab, "mte_CRT.exe", ComApp, c_mode ); ); // If( Test_Add_Clients > 0, If( test_show_MsgBox, MessageBox_fn( Concat( "Press Ok to start ", Char( Test_Add_Clients ), " additional Custom Apps as Clients." ), _%bt_Ok ) ); For( CLoop = Test_Clients + 1, CLoop <= j2f_clients, cLoop++, New_Client( meHost, CLoop, "mte_led.exe", _$as_custom, _$as_view ) ); ); // // - Start Value MOD 8 Stress Test ----------------------------------- If( test_show_MsgBox, If( ID_MSG_public, u_msg = Concat( "a unique public message for ", i_Els, " times." ), u_msg = Concat( i_Els, " private messages for each of the ", Char( j2f_clients ), " Clients." ) ); MessageBox_fn( Concat( "Press Ok to start Mod 8 Unit Test using ", u_msg ), _%bt_Ok ); ); // Print( Concat( "Start MOD 8 Stress Test (", i_Els, " times)", _$crlf ) ); waitTime = 0; If( ID_MSG_public, // waitTime = 0.002 * j2f_clients; // wait for syncronization If( Use_Two_ComApps, waitTime = waitTime + 0.12; // additional wait for minitab (it isn't particularly fast: 1.2 mtb64 1.5 mtb32) ); ); bt = HP Time(); For( iLoop = 1, iLoop <= Test_max_ISize, iLoop++, rnd = Col_Data[iLoop]; If( ID_MSG_public, To_UnitTest_Loop( ID_MSG_public, iloop, rnd, Test_show_res, _%msg_public ), For( CLoop = 1, CLoop <= j2f_clients, cLoop++, To_UnitTest_Loop( cloop, iloop, rnd, Test_show_res ) ) ); Wait( waitTime ); ); //- evaluate time required -------------------------------------------- et = HP Time(); rt = (et - bt) / 1000; Print( Concat( _$crlf, "Required Time (sec) : ", Char( rt / 1000 ) ) ); Print( Concat( _$crlf, "End MOD 8 Stress Test ------------------" ) ); // // - Show COM Clients, if necessary ------------------------------ If( Test_COM_App_hidden, To_Client_Show( iExcel, _$mtE_c_show ); If( Use_Two_ComApps, To_Client_Show( Minitab, _$mtE_c_show ) ); ); // - Check for data errors If( test_show_MsgBox, MessageBox_fn( "Check for [syncronized data] errors in Loop threads, using Client's MOD function", _%bt_Ok ) ); Print( Concat( _$crlf, "Start Check Error Test" ) ); // x_code = Concat( "With ", _$ObjApp, _$crlf, ".Range(", _$dq, "B1:B", i_Els, _$dq, ").FormulaR1C1 = ", _$dq, "=MOD(RC[-1],8)", _$dq, _$crlf, "End With" ); To_Client_As_Client_Code( IExcel, x_code ); // If( Use_Two_ComApps, m_code = "Let C2 = C1 - ( 8 * FLOOR(C1/8))"; To_Client_As_Client_Code( iMinitab, m_code ); ); // If( test_show_MsgBox, MessageBox_fn( "Get Client Data for comparison with original JMP data.", _%bt_Ok ) ); cX_Data = Get_Client_as_Numeric_Column( iExcel, "A1:A" || i_Els ); rnd_dt << New Column( "X_Data", Numeric, Continuous, Set Values( cX_Data ) ); cX_Data = Get_Client_as_Numeric_Column( iExcel, "B1:B" || i_Els ); rnd_dt << New Column( "X_Mod_8", Numeric, Continuous, Set Values( cX_Data ) ); If( Use_Two_ComApps, cM_Data = Get_Client_as_Numeric_Column( iMinitab, "C1" ); rnd_dt << New Column( "M_Data", Numeric, Continuous, Set Values( cM_Data ) ); cM_Data = Get_Client_as_Numeric_Column( iMinitab, "C2" ); rnd_dt << New Column( "M_Mod_8", Numeric, Continuous, Set Values( cM_Data ) ); ); rnd_dt << New Column( "X_Check", Numeric, Continuous, Formula( :Name( "X_Data" ) == :Name( "J_Data" ) ) ); rnd_dt << New Column( "X_Check8", Numeric, Continuous, Formula( :Name( "X_Mod_8" ) == :Name( "J_Mod_8" ) ) ); If( Use_Two_ComApps, rnd_dt << New Column( "M_Check", Numeric, Continuous, Formula( :Name( "M_Data" ) == :Name( "J_Data" ) ) ); rnd_dt << New Column( "M_Check8", Numeric, Continuous, Formula( :Name( "M_Mod_8" ) == :Name( "J_Mod_8" ) ) ); ); // - Check Error --------------------------------------------- Test_Error = 0; x_Sum = Col Sum( :X_Check ); x_Sum8 = Col Sum( :X_Check8 ); If( x_Sum != Test_max_ISize | x_Sum8 != Test_max_ISize, test_Error += 1; MessageBox_fn( Char( (Test_max_ISize - x_sum) + (Test_max_ISize - x_sum8) ) || " Errors processing Excel", _%bt_Ok ); ); If( Use_Two_ComApps, m_Sum = Col Sum( :M_Check ); m_Sum8 = Col Sum( :m_Check8 ); If( m_Sum != Test_max_ISize | m_Sum8 != Test_max_ISize, test_Error += 1; MessageBox_fn( Char( (Test_max_ISize - m_sum) + (Test_max_ISize - m_sum8) ) || " Errors processing Minitab", _%bt_Ok ); ); ); If( test_Error, Print( Concat( "Errors found in ", Char( test_Error ), " Client(s)." ) ), Print( "No Errors found." ); // - Show info about host and Client Processes --------------------------------------------- If( test_show_MsgBox, MessageBox_fn( Concat( "No Errors found.", _$crlf, "Now some info about Host and Client Processes" ), _%bt_Ok ) ); To_Client_As_vbs_codeFile( iExcel, _$nul_obj, j2F_Example_path || "j2f_Stress_processes.vbs" ); ); // // - Close / Release Clients ------------------------------------------ For( CLoop = 1, CLoop <= j2f_clients, cLoop++, Client_Close( CLoop ) ); Print( _$crlf || "COM Client(s) released and Custom Client(s) closed." ); If( MessageBox_fn( "Press Ok to closedown COM Clients and JMP Table or Cancel to leave them open ..", _%bt_OkCancel ) == 1, Client_CloseDown( iExcel ); If( Use_Two_ComApps, Client_CloseDown( iMinitab ) ); Close( rnd_dt, NoSave ); ); // TheClients = Concat( "Excel 2013[32] +No.COM.Custom.App[32]", If( Use_Two_ComApps, " +Minitab 19[64]", "" ) ); Final_message( TheClients, 3 ); // 1 or 3 //