Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private const int max = 10485760;
- private static void Main()
- {
- int[] numbers = new int[max];
- Console.WriteLine("Starting number loading with ConsoleHelper");
- Stopwatch timer = Stopwatch.StartNew();
- using (ConsoleHelper console = new ConsoleHelper())
- {
- for (int i = 0; i < max; i++)
- {
- numbers[i] = console.NextInt();
- }
- }
- timer.Stop();
- Console.WriteLine("Time taken to load all values: " + timer.Elapsed.TotalSeconds + "s");
- Console.WriteLine("Starting number loading with Regular Console");
- TextReader std = Console.In;
- numbers = new int[max];
- timer.Restart();
- Console.SetIn(File.OpenText(@"../../input.txt"));
- string[] splits = Console.ReadLine().Split(' ');
- for (int i = 0; i < max; i++)
- {
- numbers[i] = int.Parse(splits[i]);
- }
- Console.In.Close();
- timer.Stop();
- Console.SetIn(std);
- Console.WriteLine("Time taken to load all values: " + timer.Elapsed.TotalSeconds + "s");
- Console.ReadLine();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement