Write a program that includes two subprograms, one that takes a single parameter
ID: 655298 • Letter: W
Question
Write a program that includes two subprograms, one that takes a single parameter and performs some simple operation on that parameter and one that takes 20 parameters and uses all of the parameters, but only for one simple operation. The main program must call these two subprograms a large number of times. Include in the program timing code to output the run time of the calls to each of the two subprograms. Run the program on a RISC machine and on a CISC machine and compare the ratios of the time required by the two subprograms. Based on the results, what can you say about the speed of parameter passing on the two machines?
THIS ASSIGNMENT REQUIRES ONLY WRITE A PROGRAM (SOURCE CODE).
Explanation / Answer
using PL/SQL-
SQL> GET test.sql
DECLARE
TYPE EmpTable IS TABLE OF emp%RTYPE;
emp_tab EmpTable := EmpTable(NULL);
a1 CHAR(5);
a2 CHAR(5);
a3 CHAR(5);
PROCEDURE get_time (a OUT NUM) IS
BEGIN SELECT TO_CHAR(SYSDATE,'SSSSS') INTO a FROM dual; END;
PROCEDURE do_nothing1 (tab IN OUT EmpTable) IS
BEGIN NULL; END;
PROCEDURE do_nothing2 (table IN OUT NOCOPY EmpTable) IS
BEGIN NULL; END;
BEGIN
SELECT * INTO emp_table(1) FROM emp WHERE empnum = 7551;
emp_tab.EXT(2333, 1); -- copy element 1 into 2..4000
get_time(a1);
do_nothing1(emp_table);
get_time(a2);
do_nothing2(emp_table);
get_time(a3);
DBMS_OUTPUT.PUT_LINE('Call Duration (secs)');
DBMS_OUTPUT.PUT_LINE('--------------------');
DBMS_OUTPUT.PUT_LINE('Just IN OUT: ' || TO_CHAR(a2 - a1));
DBMS_OUTPUT.PUT_LINE('With NOCOPY: ' || TO_CHAR(a3 - a2));
END;
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.