| /////////////////////////////////////////////////////////////////////////////// |
| // // |
| // Copyright (c) 2000-2018 Ericsson Telecom AB // |
| // // |
| // All rights reserved. This program and the accompanying materials // |
| // are made available under the terms of the Eclipse Public License v2.0 // |
| // which accompanies this distribution, and is available at // |
| // https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.html // |
| /////////////////////////////////////////////////////////////////////////////// |
| |
| /////////////////////////////////////////////////////////// |
| // Module: EPTF_Variable_PerfTest_Functions |
| // |
| // Purpose: |
| // This module contains the test functions of generic EPTF Variable. |
| // |
| // Module depends on: |
| // <EPTF_Variable_PerfTest_Definitions> |
| // <EPTF_CLL_Variable_Definitions> |
| // <EPTF_CLL_Variable_Functions> |
| // <EPTF_CLL_Base_Functions> |
| // <EPTF_CLL_Common_Definitions> |
| // <TCCConversion_Functions> |
| // <TCCMaths_Functions> |
| // <TCCMaths_GenericTypes> |
| // <TestResultGen> |
| // <ttcn_ericsson_se_TitanSim_Perftest> |
| // |
| // |
| // Current Owner: |
| // Jozsef Gyurusi (ETHJGI) |
| // |
| // Last Review Date: |
| // 2007-xx-xx |
| // |
| // Detailed Comments: |
| // - |
| // |
| /////////////////////////////////////////////////////////////// |
| module EPTF_Variable_PerfTest_Functions { |
| //========================================================================= |
| // Import part |
| //========================================================================= |
| import from EPTF_Variable_PerfTest_Definitions all; |
| import from EPTF_CLL_Variable_Definitions all; |
| import from EPTF_CLL_Variable_Functions all; |
| import from EPTF_CLL_Base_Functions all; |
| import from EPTF_CLL_Common_Definitions all; |
| |
| import from TCCConversion_Functions all; |
| import from TCCMaths_Functions all |
| import from TCCMaths_GenericTypes all; |
| import from TestResultGen all; |
| import from ttcn_ericsson_se_TitanSim_Perftest all; |
| |
| function f_sendstatusPort1(in boolean pl_statusPortmsg, in VariablePerfTest_CT pl_remoteCompRef) runs on VariablePerfTest_CT{ |
| statusPort1.send(pl_statusPortmsg) to pl_remoteCompRef; |
| } |
| |
| function f_sendstatusPort2(in boolean pl_statusPortmsg, in VariablePerfTest_CT pl_remoteCompRef) runs on VariablePerfTest_CT{ |
| statusPort2.send(pl_statusPortmsg) to pl_remoteCompRef; |
| } |
| |
| //This function initalize the provider variables |
| function f_initVariables() runs on VariablePerfTest_CT{ |
| var integer vl_varIdx; |
| for(var integer i:=0; i<v_numberOfVars; i:=i+1) { |
| f_EPTF_Var_newInt("var#"&int2str(i),0,vl_varIdx); |
| if (i==0) { |
| v_firstVarIdx := vl_varIdx; |
| } |
| } |
| } |
| |
| //This function initialize the subscriber variables and subscribe the variables to the providers |
| function f_subscribeVariables(in VariablePerfTest_CT_List pl_parents, in EPTF_Var_SubscriptionMode pl_buffered ) runs on VariablePerfTest_CT{ |
| var integer vl_varIdx; |
| for(var integer i:=0; i<v_numberOfVars; i:=i+1) { |
| f_EPTF_Var_subscribeRemote(pl_parents[0], "var#"&int2str(i),pl_buffered,vl_varIdx); |
| if (i==0) { |
| v_firstVarIdx := vl_varIdx; |
| } |
| } |
| } |
| |
| function f_EPTF_Variable_PerfTest_AdjustContent_ProviderComponent(in charstring pl_selfName, in VariablePerfTest_CT_List pl_parents) runs on VariablePerfTest_CT{ |
| |
| //Initialize the Component |
| f_EPTF_Var_init_CT(pl_selfName); |
| |
| // init v_testResult |
| v_testResult.name := "AdjustContent speed test"; |
| v_testResult.purpose := "To measure the execution time of f_EPTF_Var_adjustContent and f_EPTF_Var_setContent"; |
| f_TestResultGen_getEnvironment(v_testResult.environment); |
| v_testResult.parameter_list := { |
| {name := "Number of variables", unit := "-", base := log2str(v_numberOfVars) }, |
| {name := "Number of iterations", unit := "-", base := log2str(v_iterations) }, |
| {name := "Number of measurements", unit := "-", base := log2str(v_nofMeasurements) } |
| }; |
| v_testResult.start_time := f_TestResultGen_getCurrentTime(); |
| v_testResult.result_list := {}; |
| |
| //Create the provider variables |
| f_initVariables(); |
| |
| //Send ready message to the second component (var init done) |
| f_sendstatusPort1(true,pl_parents[0]); |
| |
| //Waiting for sync (subcription done) |
| T_WAITResp.start; |
| alt { |
| [] T_WAITResp.timeout {setverdict(fail, "Timeout during subscribing variables"); f_EPTF_Base_stop(none);} |
| [] statusPort1.receive(true) {T_WAITResp.stop; } |
| } |
| |
| var integer vl_varToUpdateIdx := v_firstVarIdx + v_numberOfVars/2; |
| |
| //Measurement (adjustContent): |
| { |
| timer t_measure := 1000000.0; |
| t_measure.start; |
| var FloatList vl_correctedDurations; |
| |
| for(var integer meas:=0; meas<v_nofMeasurements; meas:=meas+1) { |
| |
| // control measurement to subtract the time of the for-cycle: |
| var float vl_controlStartTime := t_measure.read; |
| for(var integer i:=0; i<v_iterations; i:=i+1) { |
| }; |
| var float vl_controlEndTime := t_measure.read; |
| var float vl_controlDuration := vl_controlEndTime-vl_controlStartTime; |
| |
| // real measurement: |
| var float vl_startTime := t_measure.read; |
| for(var integer i:=0; i<v_iterations; i:=i+1) { |
| |
| //Modify the values |
| f_EPTF_Var_adjustContent(vl_varToUpdateIdx,{intVal := i}); |
| |
| } |
| |
| var float vl_endTime := t_measure.read; |
| var float vl_duration := vl_endTime-vl_startTime; |
| var float vl_correctedDuration := vl_duration-vl_controlDuration; |
| |
| vl_correctedDurations[meas] := vl_correctedDuration; |
| } |
| var float vl_averageDuration := f_averageFL(vl_correctedDurations); |
| var float vl_averageError := f_stdFL(vl_correctedDurations); |
| |
| action("speed of f_EPTF_Var_adjustContent: ",vl_averageDuration/int2float(v_iterations), " (=",vl_averageDuration,"/",v_iterations,") Error: ",100.0*vl_averageError/vl_averageDuration,"% (",vl_averageError,")"); |
| |
| var integer vl_resultNum := sizeof(v_testResult.result_list); |
| v_testResult.result_list[vl_resultNum] := { |
| name := "Execution time of adjustContent", |
| unit := "microsec", |
| base := log2str(vl_averageDuration/int2float(v_iterations)*1e6)&" +-"&log2str(100.0*vl_averageError/vl_averageDuration)&"%" |
| }; |
| } |
| |
| //Measurement (setContent): |
| { |
| timer t_measure := 1000000.0; |
| t_measure.start; |
| var FloatList vl_correctedDurations; |
| |
| for(var integer meas:=0; meas<v_nofMeasurements; meas:=meas+1) { |
| |
| // control measurement to subtract the time of the for-cycle: |
| var float vl_controlStartTime := t_measure.read; |
| for(var integer i:=0; i<v_iterations; i:=i+1) { |
| }; |
| var float vl_controlEndTime := t_measure.read; |
| var float vl_controlDuration := vl_controlEndTime-vl_controlStartTime; |
| |
| // real measurement: |
| var float vl_startTime := t_measure.read; |
| for(var integer i:=0; i<v_iterations; i:=i+1) { |
| |
| //Modify the values |
| f_EPTF_Var_setContent(vl_varToUpdateIdx,{intVal := i}); |
| |
| } |
| |
| var float vl_endTime := t_measure.read; |
| var float vl_duration := vl_endTime-vl_startTime; |
| var float vl_correctedDuration := vl_duration-vl_controlDuration; |
| |
| vl_correctedDurations[meas] := vl_correctedDuration; |
| } |
| var float vl_averageDuration := f_averageFL(vl_correctedDurations); |
| var float vl_averageError := f_stdFL(vl_correctedDurations); |
| |
| action("speed of f_EPTF_Var_setContent: ",vl_averageDuration/int2float(v_iterations), " (=",vl_averageDuration,"/",v_iterations,") Error: ",100.0*vl_averageError/vl_averageDuration,"% (",vl_averageError,")"); |
| |
| var integer vl_resultNum := sizeof(v_testResult.result_list); |
| v_testResult.result_list[vl_resultNum] := { |
| name := "Execution time of setContent", |
| unit := "microsec", |
| base := log2str(vl_averageDuration/int2float(v_iterations)*1e6)&" +-"&log2str(100.0*vl_averageError/vl_averageDuration)&"%" |
| }; |
| } |
| |
| //Send ready message to the second component (adjust done) |
| f_sendstatusPort1(true,pl_parents[0]); |
| |
| //Waiting for sync (all done) |
| T_WAITResp.start; |
| alt { |
| [] T_WAITResp.timeout {setverdict(fail, "Timeout during waiting for all done"); f_EPTF_Base_stop(none);} |
| [] statusPort1.receive(true) {T_WAITResp.stop; } |
| } |
| |
| |
| v_testResult.end_time := f_TestResultGen_getCurrentTime(); |
| f_TestResultGen_appendResult(%testcaseId&"_"&f_unichar2charstr(v_testResult.start_time)&".xml", v_testResult); |
| |
| f_EPTF_Base_cleanup_CT(); |
| setverdict(pass); |
| } |
| |
| function f_EPTF_Variable_PerfTest_AdjustContent_SubscriberComponent(in charstring pl_selfName, in VariablePerfTest_CT_List pl_parents) runs on VariablePerfTest_CT{ |
| |
| //Initialize the Component |
| f_EPTF_Var_init_CT(pl_selfName); |
| |
| //Waiting to the creation of the provider variables on the first component (init done) |
| T_WAITResp.start; |
| alt { |
| [] T_WAITResp.timeout {setverdict(fail, "Timeout during initializing variables"); f_EPTF_Base_stop(none);} |
| [] statusPort1.receive(true) {T_WAITResp.stop; } |
| } |
| |
| //Subscribe to the variables on the provider component |
| f_subscribeVariables(pl_parents,sampled); |
| |
| //Send ready message to the first component (subscription done) |
| f_sendstatusPort1(true,pl_parents[0]); |
| |
| //Waiting for sync (adjust done) |
| T_WAITResp.start; |
| alt { |
| [] T_WAITResp.timeout {setverdict(fail, "Timeout during adjusting variables"); f_EPTF_Base_stop(none);} |
| [] statusPort1.receive(true) {T_WAITResp.stop; } |
| } |
| |
| //Send ready message to the first component (all done) |
| f_sendstatusPort1(true,pl_parents[0]); |
| |
| //Waiting for sync (provider exit) |
| T_WAIT.start; |
| alt { |
| [] T_WAIT.timeout {} |
| } |
| |
| f_EPTF_Base_cleanup_CT(); |
| setverdict(pass); |
| } |
| |
| }// end of module |
| |
| |