% Sample m-file for graphing Hw1 results
% Modified by Mo-Hsi Su (8/5/97)

% Vector of cache sizes for x-axis
cache_size = [
  256
  512
  1024
  2048
  4096
  8192
  16384
  32768
  65536
  131072
  262144
  524288
  1048576
  ];


% The input files from *_result.m should be in this format
%
% Fetches = total number of cache accesses (i.e. Demand Fetches)
% Misses = vector of total number of cache misses (i.e. Demand Misses)
%
% Make sure your misses vector is correctly matched to the cache_size
% vector.


% Load Dinero result from a.trace and graph it
a_result.m;
% Find the miss rate (for y-axis)
miss_rate = Misses/Fetches;
% Graph the outputs on a log scale
semilogx(cache_size,miss_rate);


% Hold the graph for the other 2 plots
hold;
% Put a background grid on the graph
grid;

% Load Dinero result from b.trace and graph it
b_result.m;
% Find the miss rate (for y-axis)
miss_rate = Misses/Fetches;
% Graph the outputs on a log scale
semilogx(cache_size,miss_rate);


% Load Dinero result from c.trace and graph it
c_result.m;
% Find the miss rate (for y-axis)
miss_rate = Misses/Fetches;
% Graph the outputs on a log scale
semilogx(cache_size,miss_rate);


% Label graph
title('Plot of Cache Size vs. Miss Rate');
xlabel('Cache Size (in bytes)');
ylabel('Miss Rate (as a factor of total accesses)');

% Toggle the hold and release the graph
hold;