CnUnix

[알림판목록 I] [알림판목록 II] [글목록][이 전][다 음]
[ CnUnix ] in KIDS
글 쓴 이(By): parsec ( 먼 소 류 )
날 짜 (Date): 2002년 4월 10일 수요일 오후 07시 44분 10초
제 목(Title): bcc vs. gcc


PC cygwin 환경에서 Borland 의 commandline compiler인 bcc 5.5 와 gcc 2.95.3-5
를 한번 비교해 봤는데요, 최적화 옵션 안주고 그냥 컴파일해보니까 bcc(bcc32)
로 만든 실행화일은 53248 byte, gcc로 만든 실행화일은 19198 byte로 큰 차이가
났고, 실행 속도면에서는 n=50으로 주고 실행전, 후에 date 명령으로 시간을
찍어주게 하고서 돌려보니 bcc는 약 1분 남짓, gcc로 만든 건 2분 가까이 되는군요.
최적화 옵션은 안써봐서 두 개의 디폴트가 같은지는 모르겠고, 혹시 bcc 와 gcc
벤치마킹 제대로 해보신 분이 있으면 얘길 듣고 싶어서 이런 이야기를 하게 됐습
니다.
bcc commandline tool이나 gcc 모두 공짜로 쓸 수 있는 프로그램이니 머 어느쪽
광고하자는 건 아니란 건 이실테죠?


다음은 source file:

---------------------- etn_test.c --------------------------
#include <stdio.h>
#include <stdlib.h>

extern int etn(int, int);
int flag_etn_calc_fin=0;
int main(int argc, char *argv[])
{
        int i, num, n=10;
        if(argc>1) n=atoi(argv[1]);
        for(i=0; i<=(n-1)*(n-1); i++)
                if(num=etn(i,n)) printf("etn(%d,%d)=%d\n", i,n,num);
        return 0;
}
----------------------  etn.c ------------------------------
#include <stdlib.h>
extern int flag_etn_calc_fin;
int etn(int m, int n) {
        static int *num;
        static int n_prev = 0;
        static int atot;
        int area;
        int ia, ja, ib, jb, ic, jc;

        if (!flag_etn_calc_fin || n_prev != n) {
                n_prev = n;
                atot = (n-1)*(n-1);
                if(num != NULL) free(num);
                num = malloc(sizeof(int)*(atot+1));
                for(area=0; area<=atot; area++) num[area] = 0;
                for(ia=0; ia<n; ia++) for(ja=0; ja<n-ia; ja++)
                for(ib=0; ib<n; ib++) for(jb=0; jb<n-ib; jb++)
                for(ic=0; ic<n; ic++) for(jc=0; jc<n-ic; jc++) {
                        area=abs((ib-ia)*(jc-ja)-(jb-ja)*(ic-ia));
                        if(area!=0) num[area]++;
                }
                for(area=0; area<=atot; area++) num[area]/=6;
                flag_etn_calc_fin = ~0;
        }

        return num[m];
}
------------------------------------------------------

컴파일 명령 및 옵션:
$ bcc32 -etest2.exe etn.c etn_test.c
$ gcc -o test1 etn.c etn_test.c

테스트 런:
$ (date; test2 50 ; date) > bcctest2.txt
$ (date; test1 50 ; date) > gcctest1.txt

             ◇    ~~~_ _
            ∴      ~|~| |     _/__,         SEP. 11. 2001
         _ ∴∴ _    ~ | |      \ `         Armorica under a tat
      ,-| `,-,_| |__ | | |   A
______|_|__|_|___|__|| | |__|_|_____________________________________
[알림판목록 I] [알림판목록 II] [글 목록][이 전][다 음]
키 즈 는 열 린 사 람 들 의 모 임 입 니 다.