|
-
Which method is a better way to code?
let the logging package decide when to log.
Code:
BEGIN
my_log_package.start_logging (
'test', 'test', my_log_package.g_no_logging,
TRUE, FALSE, 80 );
FOR i IN 1..10000000
LOOP
my_log_package.record_event('TEST','TRUE',
my_log_package.g_detail_logging);
END LOOP;
END;
/
or putting an if statement in the code to decide
whether or not to call the logging package.
Code:
BEGIN
my_log_package.start_logging (
'test', 'test', my_log_package.g_no_logging,
TRUE, FALSE, 80 );
FOR i IN 1..10000000
LOOP
IF my_log_package.g_detail_logging <=
my_log_package.g_no_logging
THEN
my_log_package.record_event('TEST','TRUE',
my_log_package.g_detail_logging);
END IF;
END LOOP;
END;
/
-
I would go for the first one because the logging leaves less of a footprint in the code. Also, a lot of people think it's a bad idea to accesss the global variables of another package directly - you should always do it via some sort of function, so that you have more control over what is done to the variable. You can always check the global variable as the first statement in the start_logging package. Either way, you're having to make a call to the get_logging package - either to call the function or to access its global variable, so I doubt if there would be much difference in performance.
-
 Originally Posted by Scorby
I would go for the first one because the logging leaves less of a footprint in the code. Also, a lot of people think it's a bad idea to accesss the global variables of another package directly - you should always do it via some sort of function, so that you have more control over what is done to the variable. You can always check the global variable as the first statement in the start_logging package. Either way, you're having to make a call to the get_logging package - either to call the function or to access its global variable, so I doubt if there would be much difference in performance.
The variable is really a constant. And using a constant in the header might have less of an impact of performance than using a funtion. I ran the segments of code through 100 million loops and with that number of executions there was an 18 minute difference in time. However over 10 million executions the difference was only about 10 seconds. I don't plan on the code being executed that many times.
-
-
 Originally Posted by slimdave
I like option 1
Even though it might take up an extra 7 - 10 minutes over 100 million executions and the average procedure will have 3-4 logging statements? I need to justify the change in the logging package to my boss, who is a Java programmer. The old logging package had hardcoded values with if statements all over the place and did not log messages evenly. We only have 10 packages spread over two schemas. I also want to combine the schemas. There is a separate schema for logging, and I don't see why we need to keep that separate.
-
7-10 minutes out of how many total?
It depends as well on how many places you call this from. If you call my_log_package.start_logging from twenty different places it would be crazy to repeat the same g_detail_logging check in all of them.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|