public static void Create64BillionLinks()
        {
            string tempFilename = Path.GetTempFileName();

            using (var links = new Platform.Links.DataBase.CoreUnsafe.Pairs.Links(tempFilename, DefaultLinksSize))
            {
                ulong linksBeforeTest = links.Total;

                long linksToCreate = 64*1024*1024/Platform.Links.DataBase.CoreUnsafe.Pairs.Links.LinkSizeInBytes;

                Console.WriteLine("Creating {0} links.", linksToCreate);

                TimeSpan elapsedTime = Measure(() =>
                {
                    for (long i = 0; i < linksToCreate; i++)
                    {
                        links.Create(0, 0);
                    }
                });

                ulong linksCreated = links.Total - linksBeforeTest;
                double linksPerSecond = linksCreated/elapsedTime.TotalSeconds;

                Console.WriteLine("Current links count: {0}.", links.Total);

                Console.WriteLine("{0} links created in {1} ({2} links per second)", linksCreated, elapsedTime,
                    (long) linksPerSecond);
            }

            File.Delete(tempFilename);
        }
        public void GetSourceTest()
        {
            string tempFilename = Path.GetTempFileName();

            using (var links = new Platform.Links.DataBase.CoreUnsafe.Pairs.Links(tempFilename, DefaultLinksSize))
            {
                Console.WriteLine("Testing GetSource function with {0} Iterations.", Iterations);

                ulong counter = 0;

                //var firstLink = links.First();
                // Создаём одну связь, из которой будет производить считывание
                ulong firstLink = links.Create(0, 0);

                Stopwatch sw = Stopwatch.StartNew();

                // Тестируем саму функцию
                for (ulong i = 0; i < Iterations; i++)
                    counter += links.GetSource(firstLink);

                TimeSpan elapsedTime = sw.Elapsed;

                double iterationsPerSecond = Iterations/elapsedTime.TotalSeconds;

                // Удаляем связь, из которой производилось считывание
                links.Delete(ref firstLink);

                Console.WriteLine(
                    "{0} Iterations of GetSource function done in {1} ({2} Iterations per second), counter result: {3}",
                    Iterations, elapsedTime, (long) iterationsPerSecond, counter);
            }

            File.Delete(tempFilename);
        }
        public void TestGetTargetInParallel()
        {
            string tempFilename = Path.GetTempFileName();

            using (var links = new Platform.Links.DataBase.CoreUnsafe.Pairs.Links(tempFilename, DefaultLinksSize))
            {
                Console.WriteLine("Testing GetTarget function with {0} Iterations in parallel.", Iterations);

                long counter = 0;

                //var firstLink = links.First();
                ulong firstLink = links.Create(0, 0);

                Stopwatch sw = Stopwatch.StartNew();

                Parallel.For(0, Iterations, x =>
                {
                    Interlocked.Add(ref counter, (long) links.GetTarget(firstLink));
                    //Interlocked.Increment(ref counter);
                });

                TimeSpan elapsedTime = sw.Elapsed;

                double iterationsPerSecond = Iterations/elapsedTime.TotalSeconds;

                links.Delete(ref firstLink);

                Console.WriteLine(
                    "{0} Iterations of GetTarget function done in {1} ({2} Iterations per second), counter result: {3}",
                    Iterations, elapsedTime, (long) iterationsPerSecond, counter);
            }

            File.Delete(tempFilename);
        }
        public static void Create64BillionLinksInParallel()
        {
            string tempFilename = Path.GetTempFileName();

            using (var links = new Platform.Links.DataBase.CoreUnsafe.Pairs.Links(tempFilename, DefaultLinksSize))
            {
                ulong linksBeforeTest = links.Total;

                Stopwatch sw = Stopwatch.StartNew();

                long linksToCreate = 64*1024*1024/Platform.Links.DataBase.CoreUnsafe.Pairs.Links.LinkSizeInBytes;

                Console.WriteLine("Creating {0} links in parallel.", linksToCreate);

                Parallel.For(0, linksToCreate, x => links.Create(0, 0));

                TimeSpan elapsedTime = sw.Elapsed;

                ulong linksCreated = links.Total - linksBeforeTest;
                double linksPerSecond = linksCreated/elapsedTime.TotalSeconds;

                Console.WriteLine("{0} links created in {1} ({2} links per second)", linksCreated, elapsedTime,
                    (long) linksPerSecond);
            }

            File.Delete(tempFilename);
        }