[EDITED to include program execution time, filesize]
For windows only: here is some code that can be used to get some of what you want. This implementation returns only PeakWorkingSize, but I have included a commented copy of the struct containing all of the values you can obtain, with minor modifications. This will compile and build in ANSI C if you include the psapi.lib (part of windows SDK installation, freely down loadable here)
#include <windows.h>
#include <ansi_c.h>
#include <psapi.h>
time_t GetMemUsage(void);
int main(int argc, char *argv[])
{
DWORD start, elapsed; // for program execution time
size_t memory; //for cpu usage;
DWORD filesize=0; //for exe file size
FILE *fp;
char buf[260];
int i;
start = GetTickCount();
sprintf(buf, ".\\%s", argv[0]);
fp = fopen(buf, "r");
filesize = GetFileSize(fp, NULL);
for(i=0;i<1000000;i++); //so ticks will be more than zero
memory = GetMemUsage();
fclose(fp);
elapsed = GetTickCount() - start; //note, possible rollover,
return 0;
}
time_t GetMemUsage(void)
{
HANDLE hProcess;
PROCESS_MEMORY_COUNTERS pmc;
DWORD processID = GetCurrentProcessId();
hProcess = OpenProcess( PROCESS_QUERY_INFORMATION |
PROCESS_VM_READ,
FALSE, processID );
GetProcessMemoryInfo( hProcess, &pmc, sizeof(pmc));
CloseHandle(hProcess);
// typedef struct _PROCESS_MEMORY_COUNTERS {
// DWORD cb;
// DWORD PageFaultCount;
// SIZE_T PeakWorkingSetSize;
// SIZE_T WorkingSetSize;
// SIZE_T QuotaPeakPagedPoolUsage;
// SIZE_T QuotaPagedPoolUsage;
// SIZE_T QuotaPeakNonPagedPoolUsage;
// SIZE_T QuotaNonPagedPoolUsage;
// SIZE_T PagefileUsage;
// SIZE_T PeakPagefileUsage;
// } PROCESS_MEMORY_COUNTERS;
typedef PROCESS_MEMORY_COUNTERS *PPROCESS_MEMORY_COUNTERS;
return pmc.PeakWorkingSetSize;
}