| |
|
Did your program finish within a specified amount of time?
This tutorial shows you how to set up a test in Quest Code Tester for Oracle to determine if your program completed within the specified hundredths of seconds.
Flash tutorial explaining the topic: A brief video that shows you how to use Quest Code Tester to solve the problem posed by this topic. Step-by-step instructions: Follow these steps to replicate what we show you in the tutorial. StepsThis program performs a query against user_source for the specified number of iterations. The program includes in its header a block you can run to see how long it takes you to run a given number of iterations. From this, you will be able to determine reasonable values to use in this test. With 29000 rows in USER_SOURCE, I ran that test script and got the following results: "1 iterations" elapsed CPU time: 128 hundredths of seconds "5 iterations" elapsed CPU time: 569 hundredths of seconds "10 iterations" elapsed CPU time: 1167 hundredths of seconds I will be using the values 1, 5 and 10 in my examples below; please adjust those numbers to match your own findings. You can determine appropriate numbers by running the commented block of code included in the qctod#elapsed_time procedure. OK - from the Test Dashboard, create a new test definition by clicking on New from the Test Definition Programs right-click menu. Select qctod#elapsed_time from the list and press OK. Click OK on the Welcome to Test Builder dialog. Now you are inside Test Builder. Set up the test casesBefore diving into the details of each of the test cases, use "top down design" to brainstorm the various test cases that you will need. You do this in the Test Case list. Press the "Add test case" button to create a new test case and rename the test for each of the following names:
Now it is time to provide the details of each test case. For each of the headers below, I assume that you will click on the corresponding test case name, and then shift focus to the Test Case Editor to fill in the blanks. Elapsed time for 1 iteration (success)
Elapsed time for 5 iterations (failure)
Elapsed time for 10 iterations
Time to save/run your test!You can now save your test definition
and run your test with
a single press of the Save, Close, and Run button Source code of program tested: Compile this code in your schema so that you can build your test definition for it. CREATE OR REPLACE PROCEDURE qctod#elapsed_time (iterations_in IN PLS_INTEGER)
/*
Run the block of code below to determine useful timings for your tests.
DECLARE
l_start PLS_INTEGER;
PROCEDURE show_elapsed ( NAME_IN IN VARCHAR2 )
IS
BEGIN
DBMS_OUTPUT.put_line ( '"'
|| NAME_IN
|| '" elapsed CPU time: '
|| TO_CHAR ( DBMS_UTILITY.get_time - l_start )
|| ' hundredths of seconds'
);
END show_elapsed;
BEGIN
l_start := DBMS_UTILITY.get_time;
qctod#elapsed_time (1);
show_elapsed ( '1 iterations' );
l_start := DBMS_UTILITY.get_time;
qctod#elapsed_time (5);
show_elapsed ( '5 iterations' );
l_start := DBMS_UTILITY.get_time;
qctod#elapsed_time (10);
show_elapsed ( '10 iterations' );
l_start := DBMS_UTILITY.get_time;
END;
*/
IS
dummy PLS_INTEGER;
BEGIN
FOR indx IN 1 .. iterations_in
LOOP
SELECT COUNT (*)
INTO dummy
FROM user_source;
END LOOP;
END qctod#elapsed_time;
/
SHO ERR |
|