Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include<windows.h>
- #include<stdio.h>
- #include<limits.h>
- #include<time.h>
- #include<fstream>
- #define DIV 1024
- using namespace std;
- int main()
- {
- clock_t startTime;
- long int freeBytes;
- long int freePage;
- long int freeVirtual;
- MEMORYSTATUSEX MemoryInfo;
- GlobalMemoryStatusEx(&MemoryInfo);
- freeBytes = MemoryInfo.ullAvailPhys / DIV;
- freePage = MemoryInfo.ullAvailPageFile / DIV;
- freeVirtual = MemoryInfo.ullAvailVirtual / DIV;
- cout << "Available Physical Memory: " << MemoryInfo.ullAvailPhys / DIV << endl;
- cout << "Available Page File: " << MemoryInfo.ullAvailPageFile / DIV << endl;
- cout << "Available Virtual Memory" << MemoryInfo.ullAvailVirtual / DIV << endl;
- double Cache_size[15] = { 0.5,0.6,0.7,0.8 ,0.9, 0.95,0.99, 1.0, 1.01,1.1, 1.5, 2, 5, 10, 50 };
- long int num_of_Bytes;
- long int* num_array; //
- for (long int i = 0; i < 15; i++)
- {
- cout << "=========================================" << endl;
- cout << "Cache Size: " << Cache_size[i] << "*M" << endl;
- startTime = clock();
- num_of_Bytes = abs((long int)(Cache_size[i] * (freeBytes)));
- long int size = num_of_Bytes / sizeof(long int);
- num_array = new long int[size];
- GlobalMemoryStatusEx(&MemoryInfo);
- cout << "Available Physical Memory: " << MemoryInfo.ullAvailPhys / DIV << endl;
- cout << "Available Page File: " << MemoryInfo.ullAvailPageFile / DIV << endl;
- cout << "Available Virtual Memory: " << MemoryInfo.ullAvailVirtual / DIV << endl;
- for (long int i = 0; i < size; i++)
- {
- num_array[i] = i;
- }
- for (long int i = 0; i < size; i++)
- {
- num_array[i] += i;
- }
- delete[] num_array;
- cout << "Time elapsed: " << ((double)(clock() - startTime) / (double)CLOCKS_PER_SEC) << " seconds " << endl;
- }
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement