计算闪光利用率为C code [英] calculating FLASH utilisation by C code

查看:119
本文介绍了计算闪光利用率为C code的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想优化/减少我的软件的内存使用情况。一说我看的办法是寻找删除多余的和不必要的code。
在我的软件有很多的功能(高达3000),其可以被激活/经一种功能启用机制失活。我所要做的就是找​​到一个功能多少RAM / FLASH利用,然后开始与那些最大的评价,看看他们是否需要与否(功能不需要从code被安全地删除)。同时请注意,函数可以在其内部有一个以上的功能。

I want to optimize/reduce memory usage of my software. One of the approaches that I'm looking at is to look for removing redundant and unnecessary code. In my software there are lot of features (up to 3000) which can be activated/deactivated via a Feature Enable mechanism. What I am trying to do is to find how much RAM/FLASH a feature utilizes and then start evaluating with the biggest ones and see if they are required or not (Features not required can be safely deleted from the code). Also please note a function may have more than one feature within itself.

我们的code会是这个样子:

Our code would look something like this:

void foo (void)
{
    if(TRUE == feature1_enable)
    {
        doSomething;
    }
    if(TRUE == feature2_enable)
    {
        doSomething;
    }
    //rest of the code 
}

我怎么能计算多少FLASH里面的code if语句使用?因为它提供大约只有功能但里面没有他们的个别报表数据我不能使用最后一个环节映射文件。我想到一个解决方案是出了C $ C $的C创建装配上市文件(.alst),然后计算之内的指示大小if语句是什么,但通过这些线使用的FLASH量code。

How can I calculate how much FLASH the code inside if statements is using? I cannot use final link map file as it provides data only about the function but not individual statements inside them. One solution that I have thought is to create an assembly listing file (.alst) out of the C code and then calculate the size of the instructions within the if statements which is nothing but the amount of FLASH utilized by these lines of code.

请让还是我知道如果我在正确的轨道上,如果有一个更好/更简单的方式做到这一点?

Kindly let me know if I am on the right track or if there is a better/easier way to do this?

我使用:
处理器:MPC5554(POWER PC架构)结果
编译:迪亚布WindRiver公司

I am using: Processor: MPC5554 (POWER PC architecture)
Compiler: WindRiver Diab

如果逻辑是正确的我最终会写一个脚本来搜索能够做所需的计算。

If the logic is correct I would eventually write a script to search the enables and do the required calculations.

推荐答案

这在我脑海中唯一的解决方案,与优化工作的:

The only solution that comes to my mind that works with optimizations:

void foo (void)
{
#if 0 // disable feature 1 for size test
    if(TRUE == feature1_enable)
    {
        doSomething;
    }
#endf // feature 1

    if(TRUE == feature2_enable)
    {
        doSomething;
    }
    //rest of the code 
}

如果您需要自动化:

void foo (void)
{
#ifndef DISABLE_FEATURE_1_AT_COMPILE_TIME // disable feature 1 for size test
    if(TRUE == feature1_enable)
    {
        doSomething;
    }
#endf // feature 1

#ifndef DISABLE_FEATURE_2_AT_COMPILE_TIME // disable feature 2 for size test
    if(TRUE == feature2_enable)
    {
        doSomething;
    }
#endif // feature 2
    //rest of the code 
}

然后你就可以在你的构建脚本自动执行每一个功能,你必须独自测量功能的大小。你将有最多的工作现在将所有的定义。

Then you can automate in your build script for every feature you have and measure the size of the feature alone. The most work you will have is adding all the defines now.

这篇关于计算闪光利用率为C code的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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