Code response at Code Blocks(MinGW)How can I get the information about the Physical Memory, Virtual Memory & CPU register usage of my ".c" code running in Microsoft Visual C++ 2010 Express ?Code response with VC++ 2010 Express
First let me clarify my issues in depth. I'm new to Visual Studio. Every time I used "Code Blocks" with GNU GCC compiler (mingW). For the timing if I just focus on Physical & Virtual memory usage. Here is the small code just for testing purpose which I used with mingW. It worked properly.
#include <windows.h>
#include<stdio.h>
#include<stdlib.h>
#define DIV 1024
#define WI 7
#include <Psapi.h>
void main()
{
int a;float b;char c;
const unsigned char tmpe[320];
static const float weights[422];
printf("sz of a is %d \n",sizeof(a));
printf("sz of b is %d \n",sizeof(b));
printf("size of frames is %d \n", sizeof(tmpe));
printf("sz of c is %d \n",sizeof(c));
printf("size of yooo is %d \n", sizeof(weights));
PROCESS_MEMORY_COUNTERS_EX vm_cp;
GetProcessMemoryInfo(GetCurrentProcess(),
(PROCESS_MEMORY_COUNTERS*)&vm_cp,sizeof(vm_cp));
SIZE_T virtualMemoryusedbyMyCp = vm_cp.PrivateUsage; /* Virtual memory
currently used by current process, vm_cp = virtual memory of current process */
printf ("There are %*I64d Kbytes of virtual memory used by my Current
Process.\n",
WI, virtualMemoryusedbyMyCp/DIV);
SIZE_T physMemoryUsedbyMyCP = vm_cp.WorkingSetSize; /*Physical Memory used by
Current Process */
printf ("There are %*I64d Kbytes of Physical memory used by my Current
Process.\n",WI, physMemoryUsedbyMyCP/DIV);
}
But when I used the same code with Visual studio 2010 express
I'm getting this long list of errors which I'm unable to understand. Here is the compilation error with VS 2010 express
1>------ Build started: Project: Yooo_size code, Configuration: Debug Win32
------
1> size demo.c
1>size demo.c(50): error C2275: 'PROCESS_MEMORY_COUNTERS_EX' : illegal use of
this type as an expression
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\Psapi.h(394) : see
declaration of 'PROCESS_MEMORY_COUNTERS_EX'
1>size demo.c(50): error C2146: syntax error : missing ';' before identifier
'vm_cp'
1>size demo.c(50): error C2065: 'vm_cp' : undeclared identifier
1>size demo.c(51): error C2065: 'vm_cp' : undeclared identifier
1>size demo.c(51): error C2065: 'vm_cp' : undeclared identifier
1>size demo.c(52): error C2275: 'SIZE_T' : illegal use of this type as an
expression
1> C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\basetsd.h(421) : see
declaration of 'SIZE_T'
1>size demo.c(52): error C2146: syntax error : missing ';' before identifier
'virtualMemoryusedbyMyCp'
1>size demo.c(52): error C2065: 'virtualMemoryusedbyMyCp' : undeclared
identifier
1>size demo.c(52): error C2065: 'vm_cp' : undeclared identifier
1>size demo.c(52): error C2224: left of '.PrivateUsage' must have struct/union
type
1>size demo.c(54): error C2065: 'virtualMemoryusedbyMyCp' : undeclared
identifier
1>size demo.c(55): error C2275: 'SIZE_T' : illegal use of this type as an
expression
1>C:\Program Files\Microsoft SDKs\Windows\v7.0A\include\basetsd.h(421) : see
declaration of 'SIZE_T'
1>size demo.c(55): error C2146: syntax error : missing ';' before identifier
'physMemoryUsedbyMyCP'
1>size demo.c(55): error C2065: 'physMemoryUsedbyMyCP' : undeclared identifier
1>size demo.c(55): error C2065: 'vm_cp' : undeclared identifier
1>size demo.c(55): error C2224: left of '.WorkingSetSize' must have
struct/union type
1>size demo.c(57): error C2065: 'physMemoryUsedbyMyCP' : undeclared identifier
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========