Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.27 KB | None | 0 0
  1. #include<tchar.h>
  2. #include<iostream>
  3. #include<windows.h>
  4. #include<stdio.h>
  5. #include<limits.h>
  6. #include<time.h>
  7. #include<fstream>
  8. using namespace std;
  9. int main(int argc, char* argv[])
  10. {
  11. fstream f;
  12. f.open("output.txt", ios::out);
  13. clock_t startTime;
  14. long int freeBytes;
  15. int freePage;
  16. int freeVirtual;
  17. MEMORYSTATUS MemoryInfo;
  18. GlobalMemoryStatus(&MemoryInfo);
  19. freeBytes = MemoryInfo.dwAvailPhys;
  20. freePage = MemoryInfo.dwAvailPageFile;
  21. freeVirtual = MemoryInfo.dwAvailVirtual;
  22. cout << "Available Physical Memory: " << MemoryInfo.dwAvailPhys << endl;
  23. cout<< "Available Page File: " << MemoryInfo.dwAvailPageFile << endl;
  24. cout<< "Available Virtual Memory" << MemoryInfo.dwAvailVirtual << endl;
  25. f << "Available Physical Memory: " << MemoryInfo.dwAvailPhys << endl;
  26. f << "Available Page File: " << MemoryInfo.dwAvailPageFile << endl;
  27. f << "Available Virtual Memory" << MemoryInfo.dwAvailVirtual << endl;
  28. 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 };
  29. long int num_of_Bytes;
  30.  
  31. int *num_array; //
  32. for (int i = 0; i<15; i++)
  33. {
  34. cout<< "=========================================" << endl;
  35. cout<< "Cache Size: " << Cache_size[i] << "*M"<< endl;
  36. f << "=========================================" << endl;
  37. f << "Cache Size: " << Cache_size[i] << "*M" << endl;
  38. startTime = clock();
  39. num_of_Bytes = abs((int)(Cache_size[i] * (freeBytes)));
  40. int size = num_of_Bytes / sizeof(int);
  41. num_array = new int[size];
  42. GlobalMemoryStatus(&MemoryInfo);
  43. cout<< "Available Physical Memory: " << MemoryInfo.dwAvailPhys << endl;
  44. cout<< "Available Page File: " << MemoryInfo.dwAvailPageFile << endl;
  45. cout<< "Available Virtual Memory" << MemoryInfo.dwAvailVirtual << endl;
  46. f << "Available Physical Memory: " << MemoryInfo.dwAvailPhys << endl;
  47. f << "Available Page File: " << MemoryInfo.dwAvailPageFile << endl;
  48. f << "Available Virtual Memory" << MemoryInfo.dwAvailVirtual << endl;
  49. for (int i = 0; i < size; i++)
  50. {
  51. num_array[i] = i;
  52. }
  53. for (int i = 0; i < size; i++)
  54. {
  55. num_array[i] += i;
  56. }
  57. delete[] num_array;
  58. cout<< "Time elapsed: " << ((double)(clock() - startTime) / (double)CLOCKS_PER_SEC) << " seconds " << endl;
  59. f << "Time elapsed: " << ((double)(clock() - startTime) / (double)CLOCKS_PER_SEC) << " seconds " << endl;
  60. }
  61. system("pause");
  62. return 0;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement