Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDone is returned when the underlying file has ran out of lines. ErrDone = errors.New("no more values in the Simulator") // ErrBadLine is returned when the trace file line is unrecognizable to // the Parser. ErrBadLine = errors.New("bad line for trace format") )
Functions ¶
func Collection ¶
Collection evaluates the Simulator size times and saves each item to the returned slice.
func ParseARC ¶
ParseARC takes a single line of input from an ARC trace file as described in "ARC: a self-tuning, low overhead replacement cache" 1 by Nimrod Megiddo and Dharmendra S. Modha 1 and returns a sequence of numbers generated from the line and any error. For use with NewReader.
func ParseLIRS ¶
ParseLIRS takes a single line of input from a LIRS trace file as described in multiple papers 1 and returns a slice containing one number. A nice collection of LIRS trace files can be found in Ben Manes' repo 2.
func StringCollection ¶
StringCollection evaluates the Simulator size times and saves each item to the returned slice, after converting it to a string.
Types ¶
type Parser ¶
Parser is used as a parameter to NewReader so we can create Simulators from varying trace file formats easily.
type Simulator ¶
Simulator is the central type of the `sim` package. It is a function returning a key from some source (composed from the other functions in this package, either generated or parsed). You can use these Simulators to approximate access distributions.
func NewReader ¶
NewReader creates a Simulator from two components: the Parser, which is a filetype specific function for parsing lines, and the file itself, which will be read from.
When every line in the file has been read, ErrDone will be returned. For some trace formats (LIRS) there is one item per line. For others (ARC) there is a range of items on each line. Thus, the true number of items in each file is hard to determine, so it's up to the user to handle ErrDone accordingly.
func NewUniform ¶
NewUniform creates a Simulator returning uniformly distributed 1 (random) numbers [0, max) infinitely.