バイナリサイズ比較

(1) これをコンパイルして(リンクはしないで).textのサイズを調べる。

//#include "kharc.h"
int openWin(int xsiz, int ysiz);
int isClose(int win);
void wait(int msec);
void fillRect(int w, int xsiz, int ysiz, int x, int y, int col);
void drawLine(int w, int x0, int y0, int x1, int y1, int col);
int ff16Sqrt(int x);
int ff16Sin(int x);

void wave()
{
    int w, t, x, y, d, z, x1, y1, gx[1764], gy[1764];
    w = openWin(640, 480);
    for (t = 0; isClose(w) == 0; t++) {
        wait(8); fillRect(w, 640, 480, 0, 0, 0x000000);
        for (y1 = 0; y1 < 42; y1++) { y = y1 - 20;
            for (x1 = 0; x1 < 42; x1++) { x = x1 - 20;
                d = ff16Sqrt((x * x + y * y) * 65536);
                z = ff16Sin(((d * 652) >> 12) - 1043 * t) * 50 / (d + 327680);
                d = y1 * 42 + x1;
                gx[d] = (x * 2 - y * 2 + z * 0) * 4 + 320;
                gy[d] = (x * 2 + y * 2 + z * 1) * 2 + 240;
                if (x1 >= 1 && y1 >= 1) {
                    drawLine(w, gx[d - 43], gy[d - 43], gx[d - 42], gy[d - 42], 0x00ffff);
                    drawLine(w, gx[d - 43], gy[d - 43], gx[d -  1], gy[d -  1], 0x00ffff);
                }
            }
        }
    }
}

(2) 実験手順

>gcc --version
gcc (GCC) 3.4.5 (mingw-vista special r3)
Copyright (C) 2004 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

>gcc -c -Os 3dwave-bench.c

>objdump -h 3dwave-bench.o

3dwave-bench.o:     file format pe-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         000001e4  00000000  00000000  0000008c  2**2
                  CONTENTS, ALLOC, LOAD, RELOC, READONLY, CODE
  1 .data         00000000  00000000  00000000  00000000  2**2
                  ALLOC, LOAD, DATA
  2 .bss          00000000  00000000  00000000  00000000  2**2
                  ALLOC

(3) 結果のまとめ

108バイトuck2025.07.27版
356バイトELF 32-bit LSB relocatable, ARM, EABI5 version 1 (SYSV) (たぶんThumb)arm-linux-gnueabihf-gcc -c -Os -o a.o bench.carm-linux-gnueabihf-gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
484バイトpe-i386gcc -c -Os 3dwave-bench.cgcc (GCC) 3.4.5 (mingw-vista special r3)
527バイトELF 64-bit LSB relocatable, x86-64, version 1 (SYSV)gcc -m64 -c -Os bench.cgcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
540バイトELF 64-bit LSB relocatable, ARM aarch64, version 1 (SYSV)aarch64-linux-gnu-gcc -c -Os -o a.o bench.caarch64-linux-gnu-gcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0
601バイトELF 32-bit LSB relocatable, Intel 80386, version 1 (SYSV)gcc -m32 -c -Os bench.cgcc (Ubuntu 13.3.0-6ubuntu2~24.04) 13.3.0

トップ   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS