gnucobol-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Speed...


From: Christian Lademann (ZLS)
Subject: Speed...
Date: Wed, 30 Dec 2020 11:48:25 +0100
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:78.0) Gecko/20100101 Thunderbird/78.6.0

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@zls.de
*
*  ZLS Software GmbH
*  Frankfurter Straße 59    Telefon +49-6195-9902-0   mailto:zls@zls.de
*  D-65779 Kelkheim         Telefax +49-6195-900600   http://www.zls.de
*
*  Geschäftsführung John A. Shuter
*  Handelsregister  Amtsgericht Königstein, HRB 3105



reply via email to

[Prev in Thread] Current Thread [Next in Thread]