protected SQLiteMemoizationPerformanceTests( ILogger logger, PerformanceResultsFixture resultsFixture, InitialDatabaseSize initialDatabaseSize, long maxRowCount, SynchronizationMode syncMode) : base( logger, resultsFixture, initialDatabaseSize, SQLiteMemoizationStore.DefaultDatabaseFileName, testDirectory => new SQLiteMemoizationStore( logger, SystemClock.Instance, GenerateMemoizationConfiguration(maxRowCount, syncMode, testDirectory))) { }
protected SQLiteMemoizationPerformanceTests( ILogger logger, PerformanceResultsFixture resultsFixture, InitialDatabaseSize initialDatabaseSize, long maxRowCount, SynchronizationMode syncMode) : base( logger, resultsFixture, initialDatabaseSize, SQLiteMemoizationStore.DefaultDatabaseFileName, testDirectory => new SQLiteMemoizationStore( logger, SystemClock.Instance, new SQLiteMemoizationStoreConfiguration(testDirectory.Path) { MaxRowCount = maxRowCount, SyncMode = syncMode, // Having the journal disabled won't be indicative of real world performance. It is disabled so the tests run faster JournalMode = JournalMode.OFF })) { }
protected MemoizationPerformanceTests ( ILogger logger, PerformanceResultsFixture resultsFixture, InitialDatabaseSize initialDatabaseSize, string databaseFileName, Func <DisposableDirectory, IMemoizationStore> createStoreFunc ) : base(() => new PassThroughFileSystem(logger), logger) { _context = new Context(Logger); var itemCountEnvironmentVariable = Environment.GetEnvironmentVariable(ItemCountEnvironmentVariableName); _itemCount = itemCountEnvironmentVariable == null ? ItemCountDefault : int.Parse(itemCountEnvironmentVariable); _tracer.Debug(_context, $"Using itemCount=[{_itemCount}] (MaxRowCount=[{MaxRowCount}])"); ResultsFixture = resultsFixture; _initialDatabaseSize = initialDatabaseSize; CreateStoreFunc = createStoreFunc; _prePopulatedRootPath = FileSystem.GetTempPath() / "CloudStore" / "MemoizationPerformanceTestsPrePopulated"; if (!FileSystem.DirectoryExists(_prePopulatedRootPath)) { FileSystem.CreateDirectory(_prePopulatedRootPath); } AbsolutePath databaseFilePath = _prePopulatedRootPath / databaseFileName; if (FileSystem.FileExists(databaseFilePath)) { return; } _tracer.Always(_context, $"Creating prepopulated database at path={databaseFilePath}"); using (var disposableDirectory = new DisposableDirectory(FileSystem)) { using (var store = createStoreFunc(disposableDirectory)) { try { var startupStoreResult = store.StartupAsync(_context).Result; startupStoreResult.ShouldBeSuccess(); var createSessionResult = store.CreateSession(_context, Name); createSessionResult.ShouldBeSuccess(); using (var session = createSessionResult.Session) { try { var startupSessionResult = session.StartupAsync(_context).Result; startupSessionResult.ShouldBeSuccess(); for (var i = 0; i < MaxRowCount; i++) { var strongFingerprint = StrongFingerprint.Random(); var contentHashList = ContentHashList.Random(); var r = session.AddOrGetContentHashListAsync( _context, strongFingerprint, new ContentHashListWithDeterminism(contentHashList, CacheDeterminism.None), Token).Result; r.Succeeded.Should().BeTrue(); r.ContentHashListWithDeterminism.ContentHashList.Should().BeNull(); } } finally { var shutdownSessionResult = session.ShutdownAsync(_context).Result; shutdownSessionResult.ShouldBeSuccess(); } } } finally { var shutdownStoreResult = store.ShutdownAsync(_context).Result; shutdownStoreResult.ShouldBeSuccess(); } } FileSystem.CopyFileAsync(disposableDirectory.Path / databaseFileName, databaseFilePath, false).Wait(); } }