问题
I would like to optimize this code in order to save memory as much as possible. My questions are:
- How many bytes are currently occupied for this?
- How many bytes can be saved by new changes? and what are those changes?
- 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