public void TestPerformanceApiCallPost() { var originalprocesstime = TimeSpan.FromSeconds(5.8); var currentprocesstime = TestTimer.Time(DoPostRequest); Assert.IsTrue(currentprocesstime < originalprocesstime); }
private void TestResultForm_Load(object sender, EventArgs e) { TestTimer.StopTimer(); TimerResultLabel.Text = $"Тест пройдено за: {TestTimer.time.ToString("mm:ss")}"; List <Specialty> specialties = PreferredSpecialtiesDeterminant.GetDetermineSpecialties(); titleLabel.Text = $"{User.name}, за результатами тесту вам більш підходять такі спеціальності як:"; try { firstSpecialtyNameMaterialLabel.Text = specialties[0].name; firstSpecialtyDescriptionLabel.Text = specialties[0].description; firstSpecialtyProfessionsLabel.Text = GetProfessionsStr(specialties[0].professions); secondSpecialtyNameMaterialLabel.Text = specialties[1].name; secondSpecialtyDescriptionLabel.Text = specialties[1].description; secondSpecialtyProfessionsLabel.Text = GetProfessionsStr(specialties[1].professions); thirdSpecialtyNameMaterialLabel.Text = specialties[2].name; thirdSpecialtyDescriptionLabel.Text = specialties[2].description; thirdSpecialtyProfessionsLabel.Text = GetProfessionsStr(specialties[2].professions); } catch (Exception ex) { string message = "Неможливо отримати дані. Перевірте цілісність файлів."; ExceptionHandler.CriticalException(ex, message); } }
public void Init() { _variantMemoryCache = new MemoryCache("VariantCache"); _invariantMemoryCache = new MemoryCache("InVariantCache"); _variantsMemoryCache = new MemoryCache("VariantsCache"); //force markets to be loaded _timer = new TestTimer(false); _timer.FireOnce(TimeSpan.Zero); var specifiers = new ReadOnlyDictionary <string, string>(new Dictionary <string, string> { { "score", "1:1" } }); _cacheManager = new CacheManager(); _dataRouterManager = new TestDataRouterManager(_cacheManager); _mappingValidatorFactory = new MappingValidatorFactory(); _timer = new TestTimer(true); _variantMdCache = new VariantMarketDescriptionCache(_variantMemoryCache, _dataRouterManager, _mappingValidatorFactory, _cacheManager); _inVariantMdCache = new InvariantMarketDescriptionCache(_invariantMemoryCache, _dataRouterManager, _mappingValidatorFactory, _timer, TestData.Cultures, _cacheManager); _variantsMdCache = new VariantDescriptionListCache(_variantsMemoryCache, _dataRouterManager, _mappingValidatorFactory, _timer, TestData.Cultures, _cacheManager); _nameProvider = new NameProvider( new MarketCacheProvider(_inVariantMdCache, _variantMdCache, _variantsMdCache), new Mock <IProfileCache>().Object, new Mock <INameExpressionFactory>().Object, new Mock <ISportEvent>().Object, 41, specifiers, ExceptionHandlingStrategy.THROW ); }
protected void CleanUp(string testFolder = DefaultRuntimeFolder) { Logger.Log(Level.Verbose, "Cleaning up test."); if (_enableRealtimeLogUpload) { if (TimerTask != null) { TestTimer.Stop(); TimerTask.Dispose(); TimerTask = null; } // Wait for file upload task to complete Thread.Sleep(500); } string dir = Path.Combine(Directory.GetCurrentDirectory(), testFolder); try { if (Directory.Exists(dir)) { Directory.Delete(dir, true); } } catch (IOException) { // do not fail if clean up is unsuccessful } catch (UnauthorizedAccessException) { // do not fail if clean up is unsuccessful } }
public static void RunTestHelper(ITest test) { test.Result.Status = TestStatus.Pass; TestTimer timer = new TestTimer(); try { timer.Start(test); test.TestMethod.Invoke(test.Fixture.Instance, null); timer.Stop(); } catch (TargetInvocationException tie) { timer.Stop(); Exception exp = tie.InnerException; test.Result.Status = TestStatus.Fail; test.Result.Message.AppendLine(exp.Message); test.Result.Message.Append("EXCEPTION TYPE: "); test.Result.Message.AppendLine(exp.GetType().FullName); test.Result.SetFilteredStackTrace(exp.StackTrace); } finally { timer.Stop(); } }
public void TestInit() { _timers = new List <TestTimer>(); _timeProvider = new TestTimeProvider(); using (var db = new TestDbContext()) { //db.Database.EnsureDeleted(); //db.Database.EnsureCreated(); db.Database.ExecuteSqlRaw("delete from massive_jobs.message_queue"); db.Database.ExecuteSqlRaw("delete from massive_jobs.single_consumer_lock"); } JobsBuilder.Configure() .WithSettings("tests.", s => { s.PublishBatchSize = 300; s.ImmediateWorkersBatchSize = 1000; s.MaxDegreeOfParallelismPerWorker = 2; s.ImmediateWorkersCount = 2; s.ScheduledWorkersCount = 2; s.PeriodicWorkersCount = 2; }) .RegisterInstance <ITimeProvider>(_timeProvider) .RegisterScoped <ITimer>(f => { var timer = new TestTimer(); _timers.Add(timer); return(timer); }) .WithSqlServerBroker <TestDbContext>() .RegisterScoped <TestDbContext, TestDbContext>() .Build(); }
public void TestPerformance_JsonArray_LinkedEntities_ToObject() { var originalprocesstime = TimeSpan.FromSeconds(1.16); var currentprocesstime = TestTimer.Time(ParseObjectList_LinkedEntities); Assert.IsTrue(currentprocesstime < originalprocesstime); }
public void Init() { _memoryCache = new MemoryCache("sportEventCache"); _cacheManager = new CacheManager(); _dataRouterManager = new TestDataRouterManager(_cacheManager); _timer = new TestTimer(false); _sportEventCache = new SportEventCache(_memoryCache, _dataRouterManager, new SportEventCacheItemFactory(_dataRouterManager, new SemaphorePool(5, ExceptionHandlingStrategy.THROW), TestData.Cultures.First(), new MemoryCache("FixtureTimestampCache")), _timer, TestData.Cultures3, _cacheManager); var deserializer = new Deserializer <tournamentInfoEndpoint>(); var dataFetcher = new TestDataFetcher(); var mapperFactory = new TournamentInfoMapperFactory(); var tourDataProvider = new DataProvider <tournamentInfoEndpoint, TournamentInfoDTO>(TestData.RestXmlPath + TourInfoXml, dataFetcher, deserializer, mapperFactory); _tourApiData = deserializer.Deserialize(dataFetcher.GetData(new Uri(string.Format(TestData.RestXmlPath + TourInfoXml)))); _tourDtoData = tourDataProvider.GetDataAsync("", "en").Result; _tourCiData = (TournamentInfoCI)_sportEventCache.GetEventCacheItem(URN.Parse("sr:tournament:40")); var seasonDataProvider = new DataProvider <tournamentInfoEndpoint, TournamentInfoDTO>(TestData.RestXmlPath + SeasonInfoXml, dataFetcher, deserializer, mapperFactory); _seasonApiData = deserializer.Deserialize(dataFetcher.GetData(new Uri(string.Format(TestData.RestXmlPath + SeasonInfoXml)))); _seasonDtoData = seasonDataProvider.GetDataAsync("", "en").Result; _seasonCiData = (TournamentInfoCI)_sportEventCache.GetEventCacheItem(URN.Parse("sr:season:80242")); }
public void TestTimer_KeepRunning() { var timer = new TestTimer(1.0f, SomeTimed.RunType.KeepRunning); timer.OnUpdate(new TimeSlice(.3f)); Assert.AreEqual(0.3f, timer.TimerState); Assert.AreEqual(0.3f, timer.Progress); timer.OnUpdate(new TimeSlice(.7f)); Assert.AreEqual(0, timer.TimerState); Assert.AreEqual(0, timer.Progress); Assert.AreEqual(1, timer.finishedCount); Assert.IsFalse(timer.IsFinished); timer.OnUpdate(new TimeSlice(.7f)); Assert.AreEqual(0.7f, timer.TimerState); Assert.AreEqual(0.7f, timer.Progress); Assert.IsFalse(timer.IsFinished); timer.OnUpdate(new TimeSlice(.3f)); Assert.AreEqual(0, timer.TimerState); Assert.AreEqual(0, timer.Progress); Assert.AreEqual(2, timer.finishedCount); Assert.IsFalse(timer.IsFinished); }
public void TestPerformanceEmptyLinkedObjectCreateSequence() { var originalProcessTime = TimeSpan.FromSeconds(1.1); var currentProcessTime = TestTimer.Time(CreateEmptyLinkedEntities); Assert.IsTrue(currentProcessTime < originalProcessTime); }
public void Find() { IEnumerable <string> words = WordListLoader.Load( @"D:\Projects\perth-code-dojo-5-anagram-algorithm\AnagramAlgorithm\AlgorithmEngine\App_Data\wordlist.txt") .Where(w => w.Length >= 3 && Regex.IsMatch(w.ToString(), @"^[a-z]+$")); var sw = new Stopwatch(); sw.Reset(); sw.Start(); TestTimer tt = new TestTimer(); tt.Start(); List <string> matches = AnagramEngine.Find("webster", words.ToList()); Console.Write("webster" + " - "); foreach (var match in matches) { Console.Write(match + " "); } tt.Start(); Console.WriteLine(tt.ElapsedMilliseconds); sw.Stop(); Console.WriteLine(sw.ElapsedMilliseconds); //600 - 700 list //450 - 550 }
public async Task ScheduleTotalDurationOverridesRepeatWithoutEnd() { var expExecutionCount = 2; var expTotalDuration = TimeSpan.FromSeconds(0.5); //arrange var schedule = new Schedule() .WithInterval(TimeSpan.FromSeconds(0.3)) .FinishAfter(expTotalDuration) .Repeat(0); var action = Substitute.For <ICauseScheduledAnarchy>(); var sut = new Scheduler(schedule, action, TestTimer.WithDelays()); //act sut.StartSchedule(); var duration = await Wait.AndTimeActionAsync(() => !sut.Running, 1); //assert await action .Received(expExecutionCount) .ExecuteAsync(Arg.Any <TimeSpan?>(), Arg.Any <CancellationToken>()); duration.Should().BeCloseTo(expTotalDuration, 300); }
protected void CleanUp(string testFolder = DefaultRuntimeFolder) { Console.WriteLine("Cleaning up test."); if (TimerTask != null) { TestTimer.Stop(); TimerTask.Dispose(); TimerTask = null; } // Wait for file upload task to complete Thread.Sleep(500); string dir = Path.Combine(Directory.GetCurrentDirectory(), testFolder); try { if (Directory.Exists(dir)) { Directory.Delete(dir, true); } } catch (IOException) { // do not fail if clean up is unsuccessful } }
private void buttonStop_Click(object sender, EventArgs e) { Stopping = true; try { if (TestTimerMonitor.ThreadState == ThreadState.Running) { TestTimerMonitor.Abort(); } if (TestTimer.Enabled) { TestTimer.Stop(); } if (RunnerThread.ThreadState == ThreadState.Running) { RunnerThread.Abort(); } ChangeControlStatus(buttonRunTest, true); ChangeControlStatus(buttonStartDaemon, true); if (SeleniumChromeDriver != null) { SeleniumChromeDriver.Quit(); } } catch { // ignored } }
public void CompareWithPureReflection() { var properties = new Dictionary <string, object>(); properties.Add("Name", "Hugo"); properties.Add("Id", 0); properties.Add("UpdateTime", DateTime.Now.Date); properties.Add("Summary", "description omit"); var data = new DataModel(); FillPropertyFromDictionaryByReflection(data, properties); FillPropertyFromDictionaryByLibrary(data, properties); var mapper = ConvertFromDictionary(AMapper.CreateMap <IDictionary, DataModel>(), p => p); Mapper <IDictionary <string, object>, DataModel> .InitializePropertyMapper(ReflectionUtils.GetDictionaryValue); var times = 100000; var timeOfDirect = new TestTimer(n => FillPropertyFromDictionaryByDirectCalls(data, properties)).TimeForTimes(times); var timeOfReflection = new TestTimer(n => FillPropertyFromDictionaryByReflection(data, properties)).TimeForTimes(times); var timeOfLibrary = new TestTimer(n => FillPropertyFromDictionaryByLibrary(data, properties)).TimeForTimes(times); var timeOfMyMapper = new TestTimer(n => FillPropertyFromDictionaryByMyMapper(data, properties)).TimeForTimes(times); var timeOfMapper = new TestTimer(n => FillPropertyFromDictionaryByAutoMapper(data, properties)).TimeForTimes(times); var timeOfFastMember = new TestTimer(n => FillPropertyFromDictionaryByFastMembers(data, properties)).TimeForTimes(times); var timeOfFasterflect = new TestTimer(n => FillPropertyFromDictionaryByFasterflect(data, properties)).TimeForTimes(times); Assert.IsTrue(timeOfReflection > timeOfLibrary); Assert.IsTrue(timeOfMapper > timeOfReflection); }
public void MultiThreadGetPropertyPerformanceTest() { var time = 20000000; var name = "Dummy"; var model = new DataModel() { Name = name }; var classSpecifiedAdapter = AdaptedAccessorFactory.Instance.GetAccessor(model); var globalTarget = String.Empty; var timeDynamic = new TestTimer(() => { globalTarget = classSpecifiedAdapter.GetProperty(model, "Title").ToNullableString(); }).TimeForTimes(time); Assert.AreEqual(name, globalTarget); var timeDynamicMT = new TestTimer(() => { globalTarget = classSpecifiedAdapter.GetProperty(model, "Title").ToNullableString(); }).TimeForTimesParallel(time, 4); Assert.AreEqual(name, globalTarget); // The performance is not improved too much by using multi-thread. Assert.IsTrue(timeDynamic.TotalMilliseconds > timeDynamicMT.TotalMilliseconds * 1.5); }
public void OnShrink(FSharpList <object> args, FSharpFunc <FSharpList <object>, string> everyShrink) { TestTimer.Stop(); RunnerImplementation.OnShrink(args, everyShrink); numberOfShrinks++; if (!isDetailedTraces) { if (isRunningTests && FsCheckRunnerConfig.TraceNumberOfRuns) { isRunningTests = false; FormattableString.Invariant($"Failed test: {latestNumTests} / {MaxTest}"); } if (isRunningShrinks && FsCheckRunnerConfig.TraceNumberOfRuns) { Trace( FormattableString.Invariant( $"Ran shrink: {numberOfShrinks} in {TestTimer.ElapsedMilliseconds:n0}ms" ) ); } isRunningShrinks = true; } TestTimer.Restart(); }
public MissingDetailsElement(Action next, int x, int y) { this.next = next; picture = new PictureBox(); labelButton = new Label(); timer = new TestTimer(OnTimer, 15, 240, y); picture.ImageLocation = MissingDetailsTest.GetInfo()[0].url; //"http://psylab.info/images/c/cc/WAIS_-_%D1%81%D1%83%D0%B1%D1%82%D0%B5%D1%81%D1%82_" + "8_%D0%B7%D0%B0%D0%B4%D0%B0%D0%BD%D0%B8%D0%B5_1.png"; picture.SizeMode = PictureBoxSizeMode.StretchImage; picture.Location = new System.Drawing.Point(x, y); picture.Size = new System.Drawing.Size(500, 500); picture.TabIndex = 6; picture.TabStop = false; picture.Click += new System.EventHandler(OnDenied); picture.LoadCompleted += LoadComplete; labelButton.Location = new System.Drawing.Point(334 - x, 337 + y); labelButton.Size = new System.Drawing.Size(30, 30); labelButton.TabIndex = 4; labelButton.Text = ""; labelButton.TabStop = false; labelButton.FlatStyle = FlatStyle.Flat; labelButton.BackColor = Color.Red; labelButton.Click += new System.EventHandler(OnAccept); }
public TimerTester(TestTimer testTimer, int id) { this.testTimer = testTimer; this.id = id; this.timer = new Timer(new TimerCallback(expired), this, Timeout.Infinite, Timeout.Infinite); this.armed = false; }
static private void RepeatItem_Click(object sender, EventArgs e) { User.Reset(); PreferredSpecialtiesDeterminant.Reset(); TestTimer.StopTimer(); Navigation.ToRegistrationForm(Program.Context.MainForm); }
private void StartButton_Click(object sender, EventArgs e) { if (UuIdText.Enabled) { return; } LogText.Clear(); stopwatch.Restart(); StartButton.Enabled = false; ClearUuIdTextButton.Enabled = false; StopButton.Enabled = true; TestInfoButton.Enabled = true; try { if (Cache.CacheObjects .SolvedTestSessions .Where(session => session.Value.UuId == UuIdText.Text) .Count() == 1) { var solvedSession = Cache.CacheObjects .SolvedTestSessions .First(session => session.Value.UuId == UuIdText.Text); FinderSystem_OnDocumentIsFound(null, new OnTestDocumentIsFoundArgs(solvedSession.Key, solvedSession.Value)); } else { if (finderSystem is null) { finderSystem = new FinderSystem(client, UuIdText.Text, threadsCount, finderIterationsCount); finderSystem.OnNewDocument += FinderSystem_OnNewDocument; finderSystem.OnDocumentIsFound += FinderSystem_OnDocumentIsFound; finderSystem.OnError += FinderSystem_OnError; finderSystem.Start(); } else { finderSystem.Restart(UuIdText.Text); } } } catch (Exception exception) { OnFatalError(exception); } var testSession = finderSystem.GetTestSession(); if (testSession != null && testSession.Duration.HasValue) { splitContainer2.Panel2.Enabled = true; TestTimer.Start(); } }
public void SetUp() { ui = new Mock <UserInterface>(); sut = new Watch(ui.Object); timer = new TestTimer(); GlobalSettings.Timer = timer; }
private void RestartTimer() { while (TestTimer.Enabled) { Thread.Sleep(10000); } ChangeControlStatus(buttonStartDaemon, false); TestTimer.Start(); }
public void SetUp() { _beeperMock = new Mock <IBeeper>(); _configMock = new Mock <IConfiguration>(); _timer = new TestTimer(); _beeper = _beeperMock.Object; _config = _configMock.Object; }
public async Task DiagnosticsTests() { TestServerType serverType = TestServerType.OnPrem; SqlTestDb.CreateNew(serverType, doNotCleanupDb: true, databaseName: Common.PerfTestDatabaseName, query: Scripts.CreateDatabaseObjectsQuery); using (TestServiceDriverProvider testService = new TestServiceDriverProvider()) using (SelfCleaningTempFile queryTempFile = new SelfCleaningTempFile()) { await testService.ConnectForQuery(serverType, Scripts.TestDbSimpleSelectQuery, queryTempFile.FilePath, Common.PerfTestDatabaseName); Thread.Sleep(500); var contentChanges = new TextDocumentChangeEvent[1]; contentChanges[0] = new TextDocumentChangeEvent() { Range = new Range { Start = new Position { Line = 0, Character = 5 }, End = new Position { Line = 0, Character = 6 } }, RangeLength = 1, Text = "z" }; DidChangeTextDocumentParams changeParams = new DidChangeTextDocumentParams { ContentChanges = contentChanges, TextDocument = new VersionedTextDocumentIdentifier { Version = 2, Uri = queryTempFile.FilePath } }; TestTimer timer = new TestTimer() { PrintResult = true }; await testService.RequestChangeTextDocumentNotification(changeParams); await testService.ExecuteWithTimeout(timer, 60000, async() => { var completeEvent = await testService.Driver.WaitForEvent(PublishDiagnosticsNotification.Type, 15000); return(completeEvent?.Diagnostics != null && completeEvent.Diagnostics.Length > 0); }); await testService.Disconnect(queryTempFile.FilePath); } }
private static void timerCallback(Object state) { TestTimer testTimer = (TestTimer)state; lock (testTimer) { testTimer.timeTimerExpired = DateTime.Now; testTimer.autoResetEvent.Set(); } }
public void StartNow_ExecutesEventImmediately() { var timer = new TestTimer(); timer.Elapsed += ActionToPerform; timer.StartNow(100000); timer.Stop(); _numberOfExecutions.Should().Be(1); }
internal HtmlReportBuilder(DataOutputModel dataOutputModel) { _scenarios = dataOutputModel.Scenarios; _stories = _scenarios.Select(scenario => scenario.GetStoryText()).Distinct().ToList(); _testTimer = dataOutputModel.TestTimer; _warnings = dataOutputModel.Warnings; BuildChartJavascript(); CreateReportWithStories(); CreateReportWithoutStories(); }
public void Init() { _memoryCache = new MemoryCache("sportEventCache"); _cacheManager = new CacheManager(); _dataRouterManager = new TestDataRouterManager(_cacheManager); _timer = new TestTimer(false); _sportEventCache = new SportEventCache(_memoryCache, _dataRouterManager, new SportEventCacheItemFactory(_dataRouterManager, new SemaphorePool(5), TestData.Cultures.First(), new MemoryCache("FixtureTimestampCache")), _timer, TestData.Cultures, _cacheManager); }
public void TestPerformanceApiCallDelete() { var client = new ExactOnlineClient(_toc.EndPoint, _toc.GetOAuthAuthenticationToken); var account = client.For <Account>().Select("ID").Where("Name+eq+'43905139517985179437'").Get().FirstOrDefault(); var originalprocesstime = TimeSpan.FromSeconds(13.0); var currentprocesstime = TestTimer.Time(() => DoDeleteRequest(account)); Assert.IsTrue(currentprocesstime < originalprocesstime); }
/// <summary> /// Executes the inner test method, gathering the amount of time it takes to run. /// </summary> /// <returns>Returns information about the test run</returns> public override MethodResult Execute(object testClass) { TestTimer timer = new TestTimer(); timer.Start(); MethodResult methodResult = InnerCommand.Execute(testClass); timer.Stop(); methodResult.ExecutionTime = timer.ElapsedMilliseconds / 1000.00; return methodResult; }