/// <summary> /// Play the given workload in an incremental manner and store the results in the given file /// </summary> /// <param name="workload">The workload</param> /// <param name="employees">The amount of employees generated for the workload</param> /// <param name="path">The path for the results</param> /// <returns>The measurement results</returns> private static Results PlayWorkloadIncremental(List <WorkloadAction> workload, int employees, string path) { var sb = new StringBuilder(); watch.Restart(); var employeesCollection = new ObservableList <Employee>(); sb.AppendLine("Initializing graph"); Console.WriteLine("Running workload on incremental interface"); for (int i = 0; i < employees; i++) { workload[i].Perform(employeesCollection, sb); } watch.Stop(); var initTime = watch.ElapsedMilliseconds; var first = employeesCollection[0]; var second = employeesCollection[1]; var areConnected = Observable.Expression(() => Connectivity <Employee> .Create(e => e.Knows, employeesCollection).AreConnected(first, second)); ScenarioGenerator.Evaluation = () => areConnected.Value.ToString(); sb.AppendFormat("Will query whether {0} and {1} are connected", first.Name, second.Name); sb.AppendLine(); watch.Restart(); for (int i = employees; i < workload.Count; i++) { workload[i].Perform(employeesCollection, sb); } watch.Stop(); var main = watch.ElapsedMilliseconds; File.WriteAllText(path, sb.ToString()); Console.WriteLine("Completed. Incremental took {0}ms", watch.ElapsedMilliseconds); // Memory meter takes a lot of time for the incremental algorithm // Comment this line, if you wish to make runtime measurements, only //var memory = MemoryMeter.ComputeMemoryConsumption(incQuery); return(new Results() { Initialization = initTime, MainWorkload = main }); }
private static Expression <Func <bool> > CreateConnectivityAnalysis(IEnumerableExpression <Employee> employees, Employee a, Employee b) { return(() => Connectivity <Employee> .Create(e => e.Knows, employees).AreConnected(a, b)); }