Calculate the memory usage and improve computation performance

喜欢而已 提交于 2020-04-18 03:48:50

问题


I would like to optimize this code in order to save memory as much as possible. My questions are:

  1. How many bytes are currently occupied for this?
  2. How many bytes can be saved by new changes? and what are those changes?
  3. The /Ox compiler option enables a combination of optimizations that favor speed. In some versions of the Visual Studio IDE and the compiler help message, this is called full optimization, but the /Ox compiler option enables only a subset of the speed optimization options enabled by /O2. Can you contribute to an answer and do this comparison?
#include <iostream>;
using namespace std;
int main() {
    // Get numbers and show them on screen
    float n;
    int long  m, l, k ;
    cout << "Enter the number: ";
    cin >> n>> m>> l>> k;
    n += 10.1;
    n -= 3;
    l %= 3;
    ++k; 
    cout << "Your numbers are: " << n << " , " << m << " , " << l << " , " << k;
    if (l % m) cout << l << " is devisible by " <<m;
    else cout << l << "is not devisible by " << m;
        return 0; 
}

来源:https://stackoverflow.com/questions/60819407/calculate-the-memory-usage-and-improve-computation-performance

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!