/// <summary> /// Creates (N) virtual directories in memory /// using the <see cref="RipperFolder"/> class /// with ~(N/2) <see cref="RipperFile"/>(s) thrown in /// and reads all the files back into memory. /// </summary> /// <returns></returns> private TimeSpan RunVirtualFolderMatrix() { var sw = Stopwatch.StartNew(); List <RipperFolder> lstFolders = new List <RipperFolder>(); List <RipperFile> lstFiles = new List <RipperFile>(); Random rnd = new Random(); Random rnd2 = new Random(); ulong NUM_FOLDERS = this.rs.IterationsRAMFolderMatrix; ulong NUM_FILES = this.rs.IterationsRAMFolderMatrix / 2; const int num_rnd_data = 5; // Create N folders with ~N/2 files randomly in them. // Naming convention of folder and files are in HEX. // File and Folders contain the same name if they are derived. for (ulong i = 0; i < NUM_FOLDERS; i++) { lstFolders.Add(new RipperFolder($"folder{string.Format("0x{0:X}", i)}", $"path={string.Format("0x{0:X}", i)}", true, rnd2.Next(2) == 0 ? null : new RipperFile($"file{string.Format("0x{0:X}", i)}", GenerateData(ref rnd, num_rnd_data), num_rnd_data))); } // read all files in the directories foreach (RipperFolder dir in lstFolders) { RipperFile file = dir.File; } sw.Stop(); return(sw.Elapsed); }
/// <summary> /// Parameterized constructor for creating a /// <see cref="RipperFolder"/>. /// </summary> /// <param name="folderName">The name of the /// <see cref="RipperFolder"/>. <para>i.e. /// "folder{ <see langword="N"/> }" /// where <see langword="N"/> represents a number.</para> /// </param> /// <param name="path">The path of the /// <see cref="RipperFolder"/>. <para> /// [Virtually] i.e. "path={ <see langword="N"/> }" /// where <see langword="N"/> represents a number.</para> /// <para> /// [On Disk] i.e. "path={ <see langword="P"/> }" /// where <see langword="P"/> represents a path on disk.</para></param> /// <param name="isVirtual">Represents if a given <see cref="RipperFolder"/> /// is virtual or not. /// <para>Useful for checking how the path is different. /// <para>Usage: if (this.isVirtual) { // parse path as virtual }</para> /// </para></param> /// <param name="file">A <see cref="RipperFile"/> instance. Can be passed with null /// if no <see cref="RipperFile"/> exists for this <see cref="RipperFolder"/>.</param> public RipperFolder(string folderName, string path, bool isVirtual, RipperFile file) { this.FolderName = folderName; this.Path = path; this.IsVirtual = isVirtual; this.File = file; }