public async Task LoadAsync(string dirPath) { _log.InfoFormat("Dumping filesystem '{0}'...", dirPath); var baseDir = new DirectoryInfo(dirPath); var loader = new SafeFileIterator_v2(); var stopwatch = Stopwatch.StartNew(); _files = await Task.Run(() => loader.Enumerate(baseDir).ToList()); _log.InfoFormat("Total found: {0}. Time: {1}. Rate: {2}", _files.Count, stopwatch.Elapsed, stopwatch.ItemsPerSecond(_files.Count)); }
public async Task LoadAndSaveAsync(string dirPath) { const string volume = "TEST"; const int commitSize = 1000; _log.InfoFormat("LoadAndSaveAsync: '{0}'...", dirPath); var baseDir = new DirectoryInfo(dirPath); var loader = new SafeFileIterator_v2(); var stopwatch = Stopwatch.StartNew(); var position = 0; Repository repository = null; foreach (var file in loader.Enumerate(baseDir)) { if (repository == null) repository = _repositoryManager.CreateRepository(); repository.Add(file, volume); ++position; if (position % commitSize != commitSize - 1) continue; stopwatch.Stop(); _log.InfoFormat("Commiting... Position: {0}", position); stopwatch.Start(); await repository.SaveChangesAsync(); repository.Dispose(); repository = null; } if (repository != null) { stopwatch.Stop(); _log.InfoFormat("Final Commit... Position: {0}", position); stopwatch.Start(); await repository.SaveChangesAsync(); repository.Dispose(); } stopwatch.Stop(); _log.InfoFormat("FileEntries saved. Time: {0}. Count: {1}", stopwatch.Elapsed, position); }