1. Limited time only! Sign up for a free 30min personal tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Memory Investigation

  1. Jun 3, 2012 #1
    Hi guys,

    I've been given the code below and asked to explain the data shown in the attached chart. Any ideas? The data shows periodicity, what could explain it? I know it has to do with memory.

    Code (Text):

    -------------------------------------------------------
    #include <iostream>
    #include <fstream>
    #include <ctime>
    #include <stdlib.h>
    #include <math.h>
    #include <windows.h>
    #include <memory.h>

    static LARGE_INTEGER liStart;
    static LARGE_INTEGER liStop;

    using namespace std;

    int main(){
        int n = 10000000;
       
        int k = 0;
        ofstream outFile ("out.txt");
        for (int stepSize = 0; stepSize < 100000; stepSize += 128){
            int * a = new int[n];
            int x = 0;
           
            for (int i = 0; i < n; i += 4096){
                x += a[i+32];
            }
               
            QueryPerformanceCounter(&liStart);
            x=0;       
            for (int i = 0; i < 100; i++){
                x += a[i * stepSize];
            }
            QueryPerformanceCounter(&liStop);      
            outFile << stepSize << '\t' << liStop.QuadPart - liStart.QuadPart<<endl;;
            outFile.flush();
            delete [] a;
        }
       
        return(0);
    }

    -------------------------------------------------------
     
    Thanks,

    Monte
     

    Attached Files:

    Last edited by a moderator: Jun 4, 2012
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: Memory Investigation
  1. Memory Space (Replies: 8)

  2. ECE Memory! (Replies: 7)

  3. Memory module (Replies: 2)

  4. Processors and memory (Replies: 1)

  5. Memory organization (Replies: 7)

Loading...