Hello gnucobol team
first of all let me point out how happy I am that there is an open
source COBOL implementation that is impressing capable and compatible
and growing from release to release. I've been experimenting with
open-cobol and gnucobol for quite some time now.
While writing some test programs for comparing computational speed, I
got the impression that there might be some bottlenecks. For example:
---(tspeed2.cob)---
identification division.
program-id. tspeed2.
data division.
working-storage section.
01 i pic 9(7) comp-5 value 0.
01 j pic s9(14) comp-5 value 0.
01 k pic 9 comp-5 value 0.
procedure division.
move 0 to j, k
perform varying i from 0 by 1 until i >= 10000000
if k = 0
add i to j
move 1 to k
else
subtract i from j
move 0 to k
end-if
end-perform
display j upon console
stop run.
---
$ cobc -x -O2 tspeed2.cob
$ time ./tspeed2
-000000005000000
real 0m0.373s
user 0m0.367s
sys 0m0.003s
---(c-tspeed2.c)---
include <stdio.h>
main() {
long i, j;
int k;
j = 0;
k = 0;
for(i = 0; i < 10000000; i++) {
if(k)
j -= i;
else
j += i;
k = !k;
}
printf("j=%ld\n", j);
}
---
$ make c-tspeed2
$ time ./c-tspeed2
j=-5000000
real 0m0.027s
user 0m0.027s
sys 0m0.000s
The C variant of this benchmark is more than 10 times faster!
I know that this just a very limited-scoped look at performance and
maybe the comparison is unfair.
But I might be missing something.
Are there other performance tweaks, besides "-O2"?
Thank you very much.
Best regards,
Christian.
--
* Christian Lademann, ZLS Software GmbH mailto:lademann@xxxxxx
*
* ZLS Software GmbH
* Frankfurter Straße 59 Telefon +49-6195-9902-0 mailto:zls@xxxxxx
* D-65779 Kelkheim Telefax +49-6195-900600 http://www.zls.de
*
* Geschäftsführung John A. Shuter
* Handelsregister Amtsgericht Königstein, HRB 3105