public LinksSourcesTreeMethods(Links links, LinksHeader* header) { _db = links; _links = links._links; _header = header; }
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 LinksTargetsTreeMethods(Links links, LinksHeader* header) { _db = links; _links = links._links; _header = header; }
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 void TestRandomSearchAll() { string tempFilename = Path.GetTempFileName(); using (var links = new Platform.Links.DataBase.CoreUnsafe.Pairs.Links(tempFilename, DefaultLinksSize)) { ulong counter = 0; ulong minLink = 1UL; ulong maxLink = links.Total; ulong iterations = links.Total; var rnd = new Random((int) DateTime.UtcNow.Ticks); Console.WriteLine("Testing Random Search with {0} Iterations.", links.Total); Stopwatch sw = Stopwatch.StartNew(); for (ulong i = iterations; i > 0; i--) { ulong source = rnd.NextUInt64(minLink, maxLink); ulong target = rnd.NextUInt64(minLink, maxLink); counter += links.Search(source, target); } TimeSpan elapsedTime = sw.Elapsed; double iterationsPerSecond = iterations/elapsedTime.TotalSeconds; Console.WriteLine("{0} Iterations of Random Search done in {1} ({2} Iterations per second), c: {3}", iterations, elapsedTime, (long) iterationsPerSecond, counter); } File.Delete(tempFilename); }
public void TestEach() { string tempFilename = Path.GetTempFileName(); using (var links = new Platform.Links.DataBase.CoreUnsafe.Pairs.Links(tempFilename, DefaultLinksSize)) { ulong counter = 0; Console.WriteLine("Testing Each function."); Stopwatch sw = Stopwatch.StartNew(); links.Each(0, 0, x => { counter++; return true; }); TimeSpan elapsedTime = sw.Elapsed; double linksPerSecond = counter/elapsedTime.TotalSeconds; Console.WriteLine("{0} Iterations of Each's handler function done in {1} ({2} links per second)", counter, 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 BasicMemoryTest() { string tempFilename = Path.GetTempFileName(); using (var links = new Platform.Links.DataBase.CoreUnsafe.Pairs.Links(tempFilename, 1024*1024)) { links.TestBasicMemoryManagement(); } File.Delete(tempFilename); }
public static void TestDeletionOfAllLinks() { string tempFilename = Path.GetTempFileName(); using (var links = new Platform.Links.DataBase.CoreUnsafe.Pairs.Links(tempFilename, DefaultLinksSize)) { ulong linksBeforeTest = links.Total; Console.WriteLine("Deleting all links"); TimeSpan elapsedTime = Measure(links.DeleteAllLinks); ulong linksDeleted = linksBeforeTest - links.Total; double linksPerSecond = linksDeleted/elapsedTime.TotalSeconds; Console.WriteLine("{0} links deleted in {1} ({2} links per second)", linksDeleted, elapsedTime, (long) linksPerSecond); } 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); }