Example #1
0
        /// <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>();

            var incQuery = CreateQuery(employeesCollection).AsNotifiable();

            Console.WriteLine("Running workload on incremental interface");

            for (int i = 0; i < employees; i++)
            {
                workload[i].Perform(employeesCollection, incQuery, sb);
            }
            watch.Stop();
            var initTime = watch.ElapsedMilliseconds;

            watch.Restart();
            for (int i = employees; i < workload.Count; i++)
            {
                workload[i].Perform(employeesCollection, incQuery, 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, MemoryConsumption = memory
            });
        }
Example #2
0
        /// <summary>
        /// Play the given workload in a batch version 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 PlayWorkloadBatch(List <WorkloadAction> workload, int employees, string path)
        {
            var sb = new StringBuilder();

            watch.Restart();

            var employeesList = new ObservableList <Employee>();

            var pollQuery = CreateQuery(employeesList);

            Console.WriteLine("Running workload on batch interface");

            for (int i = 0; i < employees; i++)
            {
                workload[i].Perform(employeesList, pollQuery, sb);
            }
            watch.Stop();
            var initTime = watch.ElapsedMilliseconds;

            watch.Restart();
            for (int i = employees; i < workload.Count; i++)
            {
                workload[i].Perform(employeesList, pollQuery, sb);
            }

            watch.Stop();
            var main = watch.ElapsedMilliseconds;

            File.WriteAllText(path, sb.ToString());

            Console.WriteLine("Completed. Batch took {0}ms", watch.ElapsedMilliseconds);

            var memory = MemoryMeter.ComputeMemoryConsumption(pollQuery);

            return(new Results()
            {
                Initialization = initTime, MainWorkload = main, MemoryConsumption = memory
            });
        }