Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static void Main(string[] args)
- {
- int defaultN = 1000;
- Stopwatch sw = new Stopwatch();
- while (true)
- {
- Console.WriteLine("Enter test elements number:");
- int n;
- if (!int.TryParse(Console.ReadLine(), out n)) n = defaultN;
- else defaultN = n;
- Console.WriteLine($"Test with {n} elements");
- List<object> list = Enumerable.Repeat(new object(), n).ToList();
- sw.Start();
- Clear(list);
- sw.Stop();
- Console.WriteLine("Clear: {0} ms", sw.ElapsedTicks / 10000D);
- GC.Collect();
- GC.WaitForPendingFinalizers();
- List<object> list2 = Enumerable.Repeat(new object(), n).ToList();
- sw.Restart();
- Reinitialize(list2);
- sw.Stop();
- Console.WriteLine("Reinitialize: {0} ms", sw.ElapsedTicks / 10000D);
- GC.Collect();
- GC.WaitForPendingFinalizers();
- List<object> list3 = Enumerable.Repeat(new object(), n).ToList();
- sw.Restart();
- ReinitializeAndCollect(list3);
- sw.Stop();
- Console.WriteLine("ReinitializeAndCollect: {0} ms", sw.ElapsedTicks / 10000D);
- Console.WriteLine("===");
- }
- }
- private static List<object> Clear(List<object> list)
- {
- list.Clear();
- return list;
- }
- private static List<object> Reinitialize(List<object> list) => new List<object>();
- private static List<object> ReinitializeAndCollect(List<object> list)
- {
- list = new List<object>();
- GC.Collect();
- GC.WaitForPendingFinalizers();
- return list;
- }
- chart = new ChartistChart() { Title = "My fancy chart" };
- series = new List<ChartistMetaValue>();
- *some code for getting the statistics*
- chart.Series.Add(series);
- chartistLineCharts.Add(chart);
- chart = new ChartistChart() { Title = "My second fancy chart" };
- series = new List<ChartistMetaValue>();
- *some code for getting the statistics*
- chart.Series.Add(series);
- chartistLineCharts.Add(chart);
- series.Clear();
Add Comment
Please, Sign In to add comment