internal async Task PersistBlobsTest() { const int numBlobs = 16; // Create an immutable container that points to the new blobs: Console.WriteLine("Creating {0} random blobs...", numBlobs); PersistingBlob[] blobs = createBlobs(numBlobs); // Now persist those blobs to the filesystem: Console.WriteLine("Persisting {0} random blobs...", numBlobs); Stopwatch sw = Stopwatch.StartNew(); var streamedBlobs = await blrepo.PersistBlobs(blobs); sw.Stop(); Console.WriteLine("Completed in {0} ms, {1} bytes/sec", sw.ElapsedMilliseconds, streamedBlobs.Sum(b => b.Value.Length) * 1000d / sw.ElapsedMilliseconds); // Repeat! for (int i = 0; i < numBlobs; ++i) { var fs = (FileStream)blobs[i].Stream; // Re-open the temporary filestream: blobs[i] = new PersistingBlob(new FileStream(fs.Name, FileMode.Open, FileAccess.Read, FileShare.Read, 8040, true)); } sw = Stopwatch.StartNew(); streamedBlobs = await blrepo.PersistBlobs(blobs); sw.Stop(); Console.WriteLine("Completed in {0} ms, {1} bytes/sec", sw.ElapsedMilliseconds, streamedBlobs.Sum(b => b.Value.Length) * 1000d / sw.ElapsedMilliseconds); }
private async Task createCommits() { PersistingBlob pblReadme = new PersistingBlob("Readme file.".ToStream()); var sblobs = await blrepo.PersistBlobs(pblReadme); trRoot = new TreeNode.Builder( new List <TreeTreeReference>(0), new List <TreeBlobReference> { new TreeBlobReference.Builder("README", sblobs[0].Value.ID) } ); var trees = new ImmutableContainer <TreeID, TreeNode>(tr => tr.ID, trRoot); await trrepo.PersistTree(trRoot.ID, trees); TreeRepositoryTestMethods.RecursivePrint(trRoot.ID, trees); cmRoot = new Commit.Builder( new List <CommitID>(0), trRoot.ID, "James S. Dunne", DateTimeOffset.Now, "Hello world." ); await cmrepo.PersistCommit(cmRoot); }
private async Task createTrees() { PersistingBlob pbHeader = new PersistingBlob("<div>Header</div>".ToStream()); sblobs = await blrepo.PersistBlobs(pbHeader); trSection1 = new TreeNode.Builder(); trSection2 = new TreeNode.Builder(); trSection3 = new TreeNode.Builder(); trImages = new TreeNode.Builder(); trCSS = new TreeNode.Builder(); trJS = new TreeNode.Builder(); trPages = new TreeNode.Builder( new List <TreeTreeReference> { new TreeTreeReference.Builder("section1", trSection1.ID), new TreeTreeReference.Builder("section2", trSection2.ID), new TreeTreeReference.Builder("section3", trSection3.ID) }, new List <TreeBlobReference>(0) ); trContent = new TreeNode.Builder( new List <TreeTreeReference> { new TreeTreeReference.Builder("images", trImages.ID), new TreeTreeReference.Builder("css", trCSS.ID), new TreeTreeReference.Builder("js", trJS.ID) }, new List <TreeBlobReference>(0) ); trTemplate = new TreeNode.Builder( new List <TreeTreeReference>(0), new List <TreeBlobReference> { new TreeBlobReference.Builder("header", sblobs[0].Value.ID) } ); trRoot = new TreeNode.Builder( new List <TreeTreeReference> { new TreeTreeReference.Builder("template", trTemplate.ID), new TreeTreeReference.Builder("content", trContent.ID), new TreeTreeReference.Builder("pages", trPages.ID) }, new List <TreeBlobReference>(0) ); rootId = trRoot.ID; trees = new ImmutableContainer <TreeID, TreeNode>(tr => tr.ID, trSection1, trSection2, trSection3, trPages, trImages, trCSS, trJS, trContent, trTemplate, trRoot); RecursivePrint(trRoot.ID, trees); }