using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
namespace ConsoleApplication1
{
/// <summary>
/// My unbelievably awesome, non-generic, Program-class.
/// ---------
/// Notes:
/// ctrl + m, ctrl + (l,o) : Collapse, expand code
/// </summary>
class Program
{
/// <summary>
/// This method defines the entry point of each csharp program. Kinda funny, eh? :)
/// </summary>
/// <param name="args">The console args.</param>
static void Main(string[] args)
{
const int NUM_ITEMS = 1000000;
List<int> list = new List<int>(NUM_ITEMS);
Stopwatch stopwatch = new Stopwatch();
{
// Insert
stopwatch.Start();
for (int i = 0; i < NUM_ITEMS; ++i)
{
list.Add(i);
}
stopwatch.Stop();
Console.WriteLine("Insert dt:" + stopwatch.ElapsedMilliseconds);
}
stopwatch.Reset();
{
// Read
long sum = 0;
stopwatch.Start();
for (int i = 0; i < NUM_ITEMS; ++i)
{
sum += list[i];
}
stopwatch.Stop();
Console.WriteLine("Read dt:" + stopwatch.ElapsedMilliseconds);
Console.WriteLine("Read sum: " + sum);
}
}
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uQ29sbGVjdGlvbnMuR2VuZXJpYzsKdXNpbmcgU3lzdGVtLkRpYWdub3N0aWNzOwp1c2luZyBTeXN0ZW0uSU87CnVzaW5nIFN5c3RlbS5UZXh0OwoKCm5hbWVzcGFjZSBDb25zb2xlQXBwbGljYXRpb24xCnsKICAgIC8vLyA8c3VtbWFyeT4KICAgIC8vLyBNeSB1bmJlbGlldmFibHkgYXdlc29tZSwgbm9uLWdlbmVyaWMsIFByb2dyYW0tY2xhc3MuCiAgICAvLy8gLS0tLS0tLS0tCiAgICAvLy8gTm90ZXM6CiAgICAvLy8gY3RybCArIG0sIGN0cmwgKyAobCxvKSA6IENvbGxhcHNlLCBleHBhbmQgY29kZQogICAgLy8vIDwvc3VtbWFyeT4KICAgIGNsYXNzIFByb2dyYW0KICAgIHsKICAgICAgICAvLy8gPHN1bW1hcnk+CiAgICAgICAgLy8vIFRoaXMgbWV0a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