public static ManagerGroup InitGroup(uint[] npageses, AlgorithmSpec[] algorithms, RunModeInfo mode) { if (npageses.Length == 1) return InitSubGroup(npageses[0], algorithms, mode); ManagerGroup group = new ManagerGroup(); foreach (uint npages in npageses) group.Add(InitSubGroup(npages, algorithms, mode)); return group; }
public static void VerifyData(ManagerGroup group) { if (group.Count < 2) return; MemoryStream[] streams = new MemoryStream[group.Count]; for (int i = 0; i < streams.Length; i++) streams[i] = (group[i].BaseDevice as MemorySimulatedDevice).Stream; long length0 = streams[0].Length; for (int i = 1; i < streams.Length; i++) { long length = streams[i].Length; if (length0 != length) throw new DataNotConsistentException(string.Format( "Verified data have different length. " + "Device 0 has {0} pages, while Device {2} has {1} pages", length0, length, i)); } foreach (MemoryStream stream in streams) stream.Seek(0, SeekOrigin.Begin); int readcount; byte[] data0 = new byte[128 * 1024], data = new byte[data0.Length]; while ((readcount = streams[0].Read(data0, 0, data0.Length)) != 0) { for (int i = 1; i < streams.Length; i++) { streams[i].Read(data, 0, data.Length); int diffpos = Utils.FindDiff(data0, data, readcount); if (diffpos != -1) throw new DataNotConsistentException(string.Format( "Verified data not consistent at Page {0} between Device 0 and Device {1}", streams[0].Position - readcount + diffpos, i)); } } }
private static ManagerGroup InitSubGroup(uint npages, AlgorithmSpec[] algorithms, RunModeInfo mode) { string algoname = null; try { ManagerGroup group = new ManagerGroup(); foreach (AlgorithmSpec algo in algorithms) { algoname = algo.Name; group.Add(Config.CreateManager(mode, algo, npages)); } return group; } catch (Exception ex) { throw new InvalidCmdLineArgumentException(string.Format( "Exception occurs when creating {0}. Details: {1}", algoname, ex.Message), ex); } }
public GroupAccessor(ManagerGroup group, bool generateData) { this.group = group; this.data = new byte[group.PageSize]; this.rand = (generateData ? new Random() : null); }
private static bool FindBug(ManagerGroup group, int count) { return false; }
private static void OperateOnTrace(ManagerGroup group, TextReader input, bool generateData) { char[] separators1 = { '#', ';', '/' }; char[] separators2 = { ' ', '\t', ',' }; GroupAccessor accessor = new GroupAccessor(group, generateData); TraceParser parser = null; string line; while ((line = input.ReadLine()) != null) { long lineCount = Interlocked.Increment(ref processedLineCount); #if DEBUG if (lineCount >= 200000) break; if (lineCount % 5000 == 0) WriteCount(Console.Error, true); if (lineCount == 5608) lineCount = 5608; #endif string[] parts = line.Split(separators1, 2); line = parts[0].Trim(separators2); if (string.IsNullOrEmpty(line)) { string nlines = Regex.Match(parts[1], @"Lines: (\d+)").Groups[1].Value; if (!string.IsNullOrEmpty(nlines)) totalLineCount = long.Parse(nlines); continue; } parts = line.Split(separators2, StringSplitOptions.RemoveEmptyEntries); if (parser == null) parser = TraceParser.CreateParser(parts); uint pageid, length; AccessType type; parser.ParseLine(parts, out pageid, out length, out type); for (uint i = 0; i < length; i++) accessor.Access(new RWQuery(pageid + i, type)); } group.CascadeFlush(); }
private static void AnalyseAndOutput(ManagerGroup group, int count) { #if ANALISE if (FindBug(group, count)) Console.WriteLine(count); #endif }