Optimize and simplfy cob_decimal_set_mpf_core#282
Optimize and simplfy cob_decimal_set_mpf_core#282dyoparis wants to merge 0 commit intoOCamlPro:gitside-gnucobol-3.xfrom
Conversation
|
From first glance: looks good to me as Can you please share your performance test in COBOL so we can easily compare the results before/after? |
|
How do i test ? |
|
We should only optimize when we know that it helps :-) |
|
Results are : Before PatchPerformance counter stats for './stuff': After PatchPerformance counter stats for './stuff': |
|
Nice test program. As you already checked with perf stat - do you checked also with perf record (or debug output) if the new code was executed? The part why the difference - even if executed - would possibly be quite small is that the string version doesn't have any temporary allocations and is very small in case of integers. .. or that may only be used with log10? I've not tested the old/new codeflow, currently just wondering - and reminding myself that I had a bunch of interesting ideas that ... were totally mood when testing them, so I've dropped them. Side note: a high performance gain can be reached with a different codegen in case of the target being a binary float item (COMP-1/COMP-2/FLOAT/DOUBLE/LONG-DOUBLE). The case The case
|
|
Hi Simon. Here is a new test with SQRT in time the argument is a perfect square the result is an integer and the integer branch is executed. IDENTIFICATION DIVISION.
PROGRAM-ID . stuff .
ENVIRONMENT DIVISION.
DATA DIVISION .
WORKING-STORAGE SECTION.
01 B FLOAT-DECIMAL-34 .
01 C BINARY-LONG UNSIGNED .
*>
PROCEDURE DIVISION .
*>------------------
*>
*>
move 1 to C .
perform do-it UNTIL C = 1000000 .
*>
goback .
*>
DO-IT.
*>------------------
*>
move function SQRT(C) TO B
*>
add 1 to C .Before Patch After Patch |
|
OK, I think this is the point to agree to "good thought, but actually takes longer because the time used is not that often and when used is only a very minor shortcut", right? BTW: it was hard for me to read your last post, so I took the freedom to reformat it (pre-defined addition for perf output, COBOL code block) - you may want to have a look via "Edit" what I did there. |
|
the last test with perfect squares integer only : IDENTIFICATION DIVISION.
PROGRAM-ID . stuff .
*>
ENVIRONMENT DIVISION.
DATA DIVISION .
WORKING-STORAGE SECTION.
01 B FLOAT-DECIMAL-34 .
01 C BINARY-LONG UNSIGNED .
01 D BINARY-LONG UNSIGNED .
*>
PROCEDURE DIVISION .
*>------------------
*>
*>
move 2 to C .
perform do-it 400000 times .
*>
goback .
*>
DO-IT.
*>------------------
*>
compute D = C * C .
move function SQRT(D) TO B
*>
add 1 to C .Before Patch Performance counter stats for './test_2': After Patch Performance counter stats for './test_2': We get a slight time saving for integers and no regression for other types. Personally, I find the code clearer. It's up to you to accept the patch or not :-) NB: it's ok for the reformating :-) |
249587f to
326ce55
Compare
|
No need to push away anythng - just close next time :-) |
For integer input value avoid loop for multiply by 10