public override SimulationResult Simulate() { var result = new SimulationResult() { tasks = origin_tasks.ToList() }; result.cpu_clips = SchdImplHelper.GetSimuResultDirectV1( from x in origin_tasks orderby x.StartTime select new SchdRestModel { task = x, rest = x.ExecuteTime, }, true, (a, i) => from y in (from x in a where x.task.StartTime <= i select new SchdRestModel { task = x.task, rest = x.rest, temp = ((double)i - (double)x.task.StartTime) / (double)x.task.ExecuteTime }) orderby y.temp descending select y ); return(result); }
public override SimulationResult Simulate() { var result = new SimulationResult() { tasks = origin_tasks.ToList() }; result.cpu_clips = SchdImplHelper.GetSimuResultDirectV2( from x in origin_tasks select new SchdRestModel { task = x, rest = x.ExecuteTime, }); return(result); }
public override SimulationResult Simulate() { var result = new SimulationResult() { tasks = origin_tasks.ToList() }; result.cpu_clips = SchdImplHelper.GetSimuResultDirectV1( from x in origin_tasks orderby x.StartTime select new SchdRestModel { task = x, rest = x.ExecuteTime, }, true, (a, i) => from x in a where x.task.StartTime <= i select x ); return(result); }
VisualData ConvertResultToVisual(SimulationResult result) { if (result == null) { throw new NullReferenceException("结果为空!"); } var convert_result = new Dictionary <string, VisualStruct>(); result.tasks.ForEach(a => convert_result[a.Name] = new VisualStruct { during = new DuringStruct(), cpu_clips = new List <Tuple <int, int> >() }); var clips = result.cpu_clips.ToList(); var swth = new List <int>(); string last = null; int start = 0, exec = 0; clips.Add(null); for (int i = 0; i < clips.Count; i++) { string current = clips[i]; if (current != null) { if (last == null) { start = i; exec = 1; } else if (current == last) { exec++; } } if (last != null && current != last) { action(string.Format("T = {0} Execute {1} During = {2} End = {3}", start.ToString().PadRight(3), last.ToString().PadRight(3), exec.ToString().PadRight(3), (start + exec).ToString().PadRight(3))); convert_result[last].cpu_clips.Add(new Tuple <int, int>(start, exec)); start = i; exec = 1; swth.Add(i); } last = current; } foreach (var kv in convert_result) { var end = kv.Value.cpu_clips.Last(); var task = result.tasks.Find(a => a.Name == kv.Key); kv.Value.during.start_time = task.StartTime; kv.Value.during.exec_time = end.Item1 + end.Item2 - task.StartTime; } return(new VisualData() { visual = convert_result, switches = swth }); }