Advertisement
Guest User

memtest_performance_experiment.cpp

a guest
Apr 12th, 2016
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <iostream>
  4.  
  5. using namespace std;
  6.  
  7.  
  8.  
  9. int main(int argc, char* argv[]) {
  10.     if (argc<3) {
  11.         cout << "Usage:" << endl << "./memtest_performance_experiment MEMORY_IN_MEGABYTES NUMBER_OF_PASSES SEED(-1=linear access)";
  12.         return -1;
  13.     }
  14.     int argPos=1;
  15.     int memoryInMegabytes = atoi(argv[argPos++]);
  16.     long long int size = memoryInMegabytes*1024l*1024l;
  17.     int numberOfPasses = atoi(argv[argPos++]);
  18.     int seed = atoi(argv[argPos++]);
  19.    
  20.     char *memory = new char[size];
  21.    
  22.     if (seed>=0) {
  23.     } else {
  24.         for (int passNo=0; passNo<numberOfPasses; passNo++) {
  25.             for (long long int index=0; index<size; index++) {
  26.                 memory[index]=(char)(index%255);
  27.             }
  28.         }
  29.         if (memory[rand()%size] > rand()%255) {
  30.             cout << "" << endl;
  31.         }
  32.     }
  33.  
  34.     delete [] memory;
  35.  
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement