SHARE
TWEET

Untitled

a guest Jun 20th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<iostream>
  2. #include<windows.h>
  3. #include<stdio.h>
  4. #include<limits.h>
  5. #include<time.h>
  6. #include<fstream>
  7. #define DIV 1024
  8. using namespace std;
  9. int main()
  10. {
  11.     clock_t startTime;
  12.     long int freeBytes;
  13.     long int freePage;
  14.     long int freeVirtual;
  15.     MEMORYSTATUSEX MemoryInfo;
  16.     GlobalMemoryStatusEx(&MemoryInfo);
  17.     freeBytes = MemoryInfo.ullAvailPhys / DIV;
  18.     freePage = MemoryInfo.ullAvailPageFile / DIV;
  19.     freeVirtual = MemoryInfo.ullAvailVirtual / DIV;
  20.     cout << "Available Physical Memory: " << MemoryInfo.ullAvailPhys / DIV << endl;
  21.     cout << "Available Page File: " << MemoryInfo.ullAvailPageFile / DIV << endl;
  22.     cout << "Available Virtual Memory" << MemoryInfo.ullAvailVirtual / DIV << endl;
  23.  
  24.     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 };
  25.     long int num_of_Bytes;
  26.     long int* num_array; //
  27.     for (long int i = 0; i < 15; i++)
  28.     {
  29.         cout << "=========================================" << endl;
  30.         cout << "Cache Size: " << Cache_size[i] << "*M" << endl;
  31.    
  32.         startTime = clock();
  33.         num_of_Bytes = abs((long int)(Cache_size[i] * (freeBytes)));
  34.         long int size = num_of_Bytes / sizeof(long int);
  35.         num_array = new long int[size];
  36.         GlobalMemoryStatusEx(&MemoryInfo);
  37.         cout << "Available Physical Memory: " << MemoryInfo.ullAvailPhys / DIV << endl;
  38.         cout << "Available Page File: " << MemoryInfo.ullAvailPageFile / DIV << endl;
  39.         cout << "Available Virtual Memory: " << MemoryInfo.ullAvailVirtual / DIV << endl;
  40.  
  41.  
  42.         for (long int i = 0; i < size; i++)
  43.         {
  44.             num_array[i] = i;
  45.         }
  46.         for (long int i = 0; i < size; i++)
  47.         {
  48.             num_array[i] += i;
  49.         }
  50.         delete[] num_array;
  51.         cout << "Time elapsed: " << ((double)(clock() - startTime) / (double)CLOCKS_PER_SEC) << " seconds " << endl;
  52.     }
  53.     system("pause");
  54.     return 0;
  55. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top