如何测量代码大小? [英] How to measure Code Size?

查看:56
本文介绍了如何测量代码大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在讨论某些功能或优化时,通常会提到代码大小.

When certain features or optimizations are discussed, Code Size is often mentioned.

虽然我当然理解基本概念,也就是说,编译为机器码的代码集合将产生 X 字节的机器码(加上静态数据),但我最近意识到我非常不确定如何实际上测量给定二进制文件的代码大小.

While I certainly understand the basic concept, that is, that a collection of code, compiled to machine code will result in X bytes of machine code (plus static data) I have recently realized that I'm very unsure how to actually measure Code Size of a given binary.

那么,您如何衡量代码大小?

您是否只检查生成的二进制文件(可执行文件",.exe)有多大?您是否需要诸如 dumpbin.exe 之类的工具或某些特定的链接器标志来获取详细结果?

Do you just check how big the resulting binary ("executable", .exe) is? Do you need a tool such as dumpbin.exe or some specific linker flags to get detailed results?

推荐答案

您可以告诉链接器生成映射文件.这提供了易于获取的最详细信息(即,无需手动对代码进行逆向工程).

You can tell the linker to produce a map file. This gives about the most detailed information that's easy to get (i.e., much short of reverse engineering the code by hand).

根据代码,在目标文件上使用 dumpbin 可以产生有意义的结果,但也可以产生简单的匿名对象"——尤其是(仅?)当您要求生成链接时代码时.

Depending on the code, using dumpbin on an object file can produce meaningful results, but can also produce simply "anonymous object" -- especially (exclusively?) when you ask for link-time code generation.

这篇关于如何测量代码大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆