[Explicit("WARNING: Could take a long time.")] // NEVER COMMIT THIS !!!!!!!!!!!!!!!!!!!!!!!!! public void Measure_parse_game_time_100_games() { var filename = @"D:\Src\PGNArchive\PGN\Modern100.pgn"; TestContext.Progress.WriteLine($"Playing all games from;"); TestContext.Progress.WriteLine($" {filename}"); PlayAllGames(PgnGame.ReadAllGamesFromFile(filename)); TestContext.Progress.WriteLine($" {filename} complete!"); }
private static (int, TimeSpan, IEnumerable <TimeSpan>) PlayFile(string file) { var fileTimes = new List <TimeSpan>(); Console.WriteLine($"*** Starting file: {file} at: {DateTime.Now}"); var fileSw = Stopwatch.StartNew(); var games = PgnGame.ReadAllGamesFromFile(file).ToList(); var gameTimes = PlayAllGames(games).ToList(); fileSw.Stop(); fileTimes.Add(fileSw.Elapsed); Console.WriteLine($"*** Finished file: {file} at {DateTime.Now}, {gameTimes.Count()} " + $"games read in {fileSw.Elapsed} {fileSw.Elapsed / gameTimes.Count()}"); return(games.Count(), fileSw.Elapsed, gameTimes); }
public IEnumerable <PgnGame> Find(FindOptions options) { var results = new List <PgnGame>(); foreach (var fileSource in options.FileSources) { var games = PgnGame.ReadAllGamesFromFile(fileSource).ToList(); OnFileRead?.Invoke(this, fileSource, games); var matchedGames = games.AsEnumerable().FindGames(options).ToList(); OnMatchesFound?.Invoke(this, matchedGames); results.AddRange(matchedGames); } return(results); }
private static void ImportGames(string[] pgnFiles, string scanPath) { Console.WriteLine("Initialising repo and cache..."); IGamesRepository repo = new GamesRepository(DbContext); Console.WriteLine($"Beginning import of {pgnFiles.Length} PGN files at: {DateTime.Now}"); var fileCount = 0; pgnFiles.ToList().ForEach(file => { fileCount++; try { Console.WriteLine($"File #{fileCount}/{pgnFiles.Length} : {file}"); var pgnGames = PgnGame.ReadAllGamesFromFile(file).ToArray(); Console.WriteLine($"Checking {pgnGames.Count()} games for new entries..."); var sw = Stopwatch.StartNew(); var createdCount = repo.AddImportBatch(pgnGames); sw.Stop(); Console.WriteLine( $" File complete, {createdCount} new games added to DB (file contained {pgnGames.Count() - createdCount} duplicates) , DB Total Games: {repo.TotalGames}"); Console.WriteLine( $" time taken: {sw.Elapsed}, games created per second: {createdCount/sw.Elapsed.Seconds}"); Archiver.ArchiveImportedFile(file, scanPath); } catch (Exception e) { Console.WriteLine($"ERROR: Importing file: {file}"); Console.WriteLine(e); var failPath = Archiver.ArchiveFailedFile(file, scanPath); Console.WriteLine($"Fail archived at: {failPath}"); if (e is SqlException) { throw; } } }); }
[Explicit("WARNING: Could take a VERY long time.")] // NEVER COMMIT THIS !!!!!!!!!!!!!!!!!!!!!!!!! public void Should_play_all_games_in_a_single_file() { // Last Test: 19/05/19 - 58.7377 Minutes - 3081 games Average playtime (00:00:01.1312775) (DEBUG) // Last Test: 21/05/19 - 15.5203 Minutes - 3081 games Average playtime (00:00:00.2983940) // var filename = @"D:\Src\PGNArchive\PGN\Adams\Adams.pgn"; // Last Test: 19/05/19 - 24.0282 Minutes - 1250 games Average playtime (00:00:01.1436758) (DEBUG) //var filename = @"D:\Src\PGNArchive\PGN\Akobian\Akobian.pgn"; // Last Test: 19/05/19 - 29.0058 Minutes - 1880 games Average playtime (00:00:00.9179160)(RELEASE) // var filename = @"D:\Src\PGNArchive\PGN\Akopian\Akopian.pgn"; // Last Test: 19/05/19 - 12.1338 - 776 Average playtime (00:00:00.9298538) (RELEASE) // Last Test: 22/05/19 - 3.8212 - 776 Average playtime (00:00:00.2911059) // var filename = @"D:\Src\PGNArchive\PGN\Alburt\Alburt.pgn"; var filename = @"D:\Src\PGNArchive\PGN\Modern100.pgn"; TestContext.Progress.WriteLine($"Playing all games from;"); TestContext.Progress.WriteLine($" {filename}"); PlayAllGames(PgnGame.ReadAllGamesFromFile(filename)); TestContext.Progress.WriteLine($" {filename} complete!"); }