/// <summary> /// Handles the login logic /// </summary> /// <param name="appSettings">The startup settings</param> /// <returns>The loginResult</returns> public static async Task <LoginResult> Login(AppSettings appSettings) { Console.WriteLine("...Login..."); var timer = new ExecutionTimer(true); LoginResult loginResult; try { if (RunModeHandler.IsDebugMode()) { bool fastLogin = bool.Parse(appSettings.GetByKey(AppSetting.FastLogin)); if (fastLogin) { loginResult = await FastLogin(); } else { loginResult = await BitwardenUIAuthManager.Login(); } } else { loginResult = await BitwardenUIAuthManager.Login(); } return(loginResult); } finally { timer.StopAndWrite(); } }
public IList <string> GetLinks(string fromUrl, string selector, string textInTitle) { if (string.IsNullOrEmpty(fromUrl)) { return(new List <string>()); } try { var timing = ExecutionTimer.GetTiming(() => _httpGet.Get(fromUrl, null, null)); _logger.Debug("Downloaded standard page", new Dictionary <string, object> { { "Url", fromUrl } }); var parser = new HtmlParser(); var result = parser.Parse(timing.Result); var all = result.QuerySelectorAll(selector); return(all.Where(x => x.TextContent.Contains(textInTitle)).Select(x => x.GetAttribute("href")).ToList()); } catch (Exception ex) { _logger.Warn(ex, "AngleSharp"); return(null); } }
protected override async Task <RunSummary> RunTestAsync() { if (_dataDiscoveryException != null) { return(RunTest_DataDiscoveryException()); } var runSummary = await TaskExecutor.RunAsync( CancellationTokenSource.Token, _testRunners.Select(r => (Func <Task <RunSummary> >)r.RunScenarioAsync).ToArray(), TestCase.TestMethod.TestClass); // Run the cleanup here so we can include cleanup time in the run summary, // but save any exceptions so we can surface them during the cleanup phase, // so they get properly reported as test case cleanup failures. var timer = new ExecutionTimer(); foreach (var disposable in _toDispose) { timer.Aggregate(() => _cleanupAggregator.Run(disposable.Dispose)); } runSummary.Time += timer.Total; return(runSummary); }
/// <summary> /// Runs an async checking instrumentation pass. /// </summary> public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } var initImpl = this.AC.GetImplementation(DeviceDriver.InitEntryPoint); this.InstrumentCheckerFunction(); this.InstrumentInitFunction(initImpl); this.VisitFunctionsInImplementation(initImpl); this.SimplifyProgram(); // HACK foreach (var proc in this.AC.TopLevelDeclarations.OfType <Procedure>()) { if (proc.Name.StartsWith("$memcpy") || proc.Name.StartsWith("$memset")) { proc.Ensures.Clear(); } } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [AsyncCheckingInstrumentation] {0}", this.Timer.Result()); } }
public async Task <IndexerResult> IndexEntries(string indexName) { // Load data var timing = ExecutionTimer.GetTiming(() => _providerDataService.LoadDatasetsAsync()); var source = await timing.Result; // Providers var providersApi = CreateApiProviders(source).ToList(); IndexApiProviders(indexName, providersApi); // Provider Sites var apprenticeshipProviders = CreateApprenticeshipProviders(source).ToList(); IndexStandards(indexName, apprenticeshipProviders); IndexFrameworks(indexName, apprenticeshipProviders); var totalAmountDocuments = GetTotalAmountDocumentsToBeIndexed(providersApi, apprenticeshipProviders); return(new IndexerResult { IsSuccessful = IsIndexCorrectlyCreated(indexName, totalAmountDocuments), TotalCount = totalAmountDocuments }); }
/// <summary> /// Runs a pair instrumentation pass. /// </summary> public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } PairCheckingRegion region = new PairCheckingRegion(this.AC, this.EP1, this.EP2); AnalysisContext.RegisterPairEntryPointAnalysisContext(region, this.EP1, this.EP2); if (this.EP1.IsInit || this.EP2.IsInit) { this.CreateDeviceStructConstant(); } this.AC.TopLevelDeclarations.Add(region.Procedure()); this.AC.TopLevelDeclarations.Add(region.Implementation()); this.AC.ResContext.AddProcedure(region.Procedure()); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [PairInstrumentation] {0}", this.Timer.Result()); } }
public void Run() { if (ToolCommandLineOptions.Get().VerboseMode) { Output.PrintLine("... LoopInvariantInstrumentation"); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var thread in this.AC.Threads) { this.CandidateCounter.Add(thread, 0); this.InstrumentThread(thread); if (ToolCommandLineOptions.Get().SuperVerboseMode) { var suffix = this.CandidateCounter[thread] == 1 ? "" : "s"; Output.PrintLine("..... Instrumented '{0}' loop invariant candidate" + suffix + " in '{1}'", this.CandidateCounter[thread], thread.Name); } } this.InstrumentExistentialBooleans(); if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer.Stop(); Output.PrintLine("..... [{0}]", this.Timer.Result()); } }
private Stream GetZipStream(string zipFilePath) { var timer = ExecutionTimer.GetTiming(() => _httpGetFile.GetFile(zipFilePath)); LogExecutionTime(zipFilePath, timer.ElaspedMilliseconds); return(timer.Result); }
void IPass.Run() { if (ToolCommandLineOptions.Get().VerboseMode) { Output.PrintLine("... LocksetInstrumentation"); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.InstrumentMainFunction(); this.AddNonCheckedFunc(); foreach (var thread in this.AC.Threads) { this.InstrumentThread(thread); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer.Stop(); Output.PrintLine("..... [{0}]", this.Timer.Result()); } }
void IPass.Run() { if (ToolCommandLineOptions.Get().VerboseMode) { Output.PrintLine("... SharedStateAbstraction"); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var impl in this.AC.TopLevelDeclarations.OfType <Implementation>().ToList()) { this.AbstractReadAccesses(impl); this.AbstractWriteAccesses(impl); // this.CleanUpModset(impl); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer.Stop(); Output.PrintLine("..... [{0}]", this.Timer.Result()); } }
// base implementation for cache invalidation that should fit all external registries protected async Task <IDictionary <ModuleReference, DiagnosticBuilder.ErrorBuilderDelegate> > InvalidateModulesCacheInternal(RootConfiguration configuration, IEnumerable <TModuleReference> references) { var statuses = new Dictionary <ModuleReference, DiagnosticBuilder.ErrorBuilderDelegate>(); foreach (var reference in references) { using var timer = new ExecutionTimer($"Delete module {reference.FullyQualifiedReference} from cache"); try { if (Directory.Exists(GetModuleDirectoryPath(reference))) { await this.TryDeleteModuleDirectoryAsync(reference); } } catch (Exception exception) { if (exception.Message is { } message) { statuses.Add(reference, x => x.ModuleDeleteFailedWithMessage(reference.FullyQualifiedReference, message)); timer.OnFail($"Unexpected exception {exception}: {message}"); return(statuses); } statuses.Add(reference, x => x.ModuleDeleteFailed(reference.FullyQualifiedReference)); timer.OnFail($"Unexpected exception {exception}."); } } return(statuses); }
void IPass.Run() { if (ToolCommandLineOptions.Get().VerboseMode) { Output.PrintLine("... GlobalRaceCheckingInstrumentation"); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var thread in this.AC.Threads) { this.AddCurrentLocksets(thread); this.AddMemoryLocksets(thread); this.AddAccessCheckingVariables(thread); if (ToolCommandLineOptions.Get().SuperVerboseMode) { Output.PrintLine("..... Instrumented lockset analysis globals for {0}", thread); } } this.AddAccessWatchdogConstants(); if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer.Stop(); Output.PrintLine("..... [{0}]", this.Timer.Result()); } }
public void Run() { if (ToolCommandLineOptions.Get().VerboseMode) { Output.PrintLine("... ErrorReportingInstrumentation"); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var thread in this.AC.Threads) { this.Thread = thread; this.InstrumentAsyncFuncs(); this.CleanUp(); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer.Stop(); Output.PrintLine("..... [{0}]", this.Timer.Result()); } }
public override async Task <IDictionary <ModuleReference, DiagnosticBuilder.ErrorBuilderDelegate> > RestoreModules(RootConfiguration configuration, IEnumerable <OciArtifactModuleReference> references) { var statuses = new Dictionary <ModuleReference, DiagnosticBuilder.ErrorBuilderDelegate>(); foreach (var reference in references) { using var timer = new ExecutionTimer($"Restore module {reference.FullyQualifiedReference}"); var(result, errorMessage) = await this.TryPullArtifactAsync(configuration, reference); if (result is null) { if (errorMessage is not null) { statuses.Add(reference, x => x.ModuleRestoreFailedWithMessage(reference.FullyQualifiedReference, errorMessage)); timer.OnFail(errorMessage); } else { statuses.Add(reference, x => x.ModuleRestoreFailed(reference.FullyQualifiedReference)); timer.OnFail(); } } } return(statuses); }
/// <summary> /// Validates ILoadTest scenario correctness by executing single test iteration /// from ScenarioSetup to ScenarioTearDown on the same thread. /// Exceptions are not handled on purpose to ease problem identification while developing. /// </summary> /// <param name="loadTestScenario">ILoadTestScenario object</param> /// <param name="threadId">TheardId to set in TestContext</param> /// <param name="threadIterationId">ThreadIterationId to set in TestContext</param> /// <param name="globalIterationId">GlobalIterationId to set in TestContext</param> /// <returns>Raw result from single iteration</returns> public static IterationResult Validate(ILoadTestScenario loadTestScenario, int threadId = 0, int threadIterationId = 0, int globalIterationId = 0) { ExecutionTimer timer = new ExecutionTimer(); TestContext testContext = new TestContext(threadId, timer); testContext.Reset(-1, -1); loadTestScenario.ScenarioSetup(testContext); testContext.Reset(threadIterationId, globalIterationId); testContext.Checkpoint(Checkpoint.IterationSetupCheckpointName); loadTestScenario.IterationSetup(testContext); testContext.Checkpoint(Checkpoint.IterationStartCheckpointName); testContext.Start(); loadTestScenario.ExecuteScenario(testContext); testContext.Stop(); testContext.Checkpoint(Checkpoint.IterationEndCheckpointName); testContext.Checkpoint(Checkpoint.IterationTearDownCheckpointName); loadTestScenario.IterationTearDown(testContext); IterationResult result = new IterationResult(testContext); testContext.Reset(-1, -1); loadTestScenario.ScenarioTearDown(testContext); return(result); }
internal void AuthenticateToAzure() { // Try to authenticate to Azure // TODO: The Azure Functions Host might supply these differently. This might change but works for the demo string applicationId = Environment.GetEnvironmentVariable("SERVICE_PRINCIPAL_APP_ID"); string applicationSecret = Environment.GetEnvironmentVariable("SERVICE_PRINCIPAL_APP_PASSWORD"); string tenantId = Environment.GetEnvironmentVariable("SERVICE_PRINCIPAL_TENANT_ID"); if (string.IsNullOrEmpty(applicationId) || string.IsNullOrEmpty(applicationSecret) || string.IsNullOrEmpty(tenantId)) { _logger.Log(LogLevel.Warning, "Required environment variables to authenticate to Azure were not present"); return; } // Build SecureString var secureString = new SecureString(); foreach (char item in applicationSecret) { secureString.AppendChar(item); } using (ExecutionTimer.Start(_logger, "Authentication to Azure completed.")) { _pwsh.AddCommand("Az.Profile\\Connect-AzAccount") .AddParameter("Credential", new PSCredential(applicationId, secureString)) .AddParameter("ServicePrincipal") .AddParameter("TenantId", tenantId) .InvokeAndClearCommands(); } }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.AddAccessFuncs(AccessType.WRITE); this.AddAccessFuncs(AccessType.READ); foreach (var region in this.AC.InstrumentationRegions) { this.InstrumentImplementation(region); } foreach (var region in this.AC.InstrumentationRegions) { this.InstrumentProcedure(region); } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [RaceInstrumentation] {0}", this.Timer.Result()); } }
private Dictionary <string, ParameterMetadata> RetriveParameterMetadata( AzFunctionInfo functionInfo, out string moduleName) { moduleName = null; string scriptPath = functionInfo.ScriptPath; string entryPoint = functionInfo.EntryPoint; using (ExecutionTimer.Start(_logger, "Parameter metadata retrieved.")) { if (String.IsNullOrEmpty(entryPoint)) { return(_pwsh.AddCommand("Microsoft.PowerShell.Core\\Get-Command").AddParameter("Name", scriptPath) .InvokeAndClearCommands <ExternalScriptInfo>()[0].Parameters); } else { moduleName = Path.GetFileNameWithoutExtension(scriptPath); return(_pwsh.AddCommand("Microsoft.PowerShell.Core\\Import-Module").AddParameter("Name", scriptPath) .AddStatement() .AddCommand("Microsoft.PowerShell.Core\\Get-Command").AddParameter("Name", entryPoint) .InvokeAndClearCommands <FunctionInfo>()[0].Parameters); } } }
public static void Main() { SelectionSort selectS = new SelectionSort(); RandomNum rNA = new RandomNum(); ExecutionTimer eT = new ExecutionTimer(); // to test execution time // int[] array = new int[] { 3,1,4,6,7,5,2 }; // random number generator for array (initialize & instantiate) //int[] test = rNA.RandNumArrGen(5, 100); int[] test2 = rNA.RandNumArrGen(10, 100); // int[] test3 = rNA.RandNumArrGen(10, 25); // ***** Tests for selectionsort() ***** // eT.startTimer(); selectS.selectionsort(test2); eT.stopTimer(); eT.elapsedTime(); } //main
protected override async Task <RunSummary> RunTestAsync() { if (this.dataDiscoveryException != null) { this.MessageBus.Queue( new XunitTest(this.TestCase, this.DisplayName), test => new TestFailed(test, 0, null, this.dataDiscoveryException.Unwrap()), this.CancellationTokenSource); return(new RunSummary { Total = 1, Failed = 1 }); } var summary = new RunSummary(); foreach (var scenarioRunner in this.scenarioRunners) { summary.Aggregate(await scenarioRunner.RunAsync()); } // Run the cleanup here so we can include cleanup time in the run summary, // but save any exceptions so we can surface them during the cleanup phase, // so they get properly reported as test case cleanup failures. var timer = new ExecutionTimer(); foreach (var disposable in this.disposables) { timer.Aggregate(() => this.cleanupAggregator.Run(() => disposable.Dispose())); } summary.Time += timer.Total; return(summary); }
protected override async Task <RunSummary> RunTestAsync() { if (_dataDiscoveryException != null) { return(RunTest_DataDiscoveryException()); } var runSummary = new RunSummary(); foreach (var testRunner in _testRunners) { runSummary.Aggregate(await testRunner.RunAsync()); } // Run the cleanup here so we can include cleanup time in the run summary, // but save any exceptions so we can surface them during the cleanup phase, // so they get properly reported as test case cleanup failures. var timer = new ExecutionTimer(); foreach (var disposable in _toDispose) { timer.Aggregate(() => _cleanupAggregator.Run(() => disposable.Dispose())); } runSummary.Time += timer.Total; return(runSummary); }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.AddUpdateLocksetFunc(); this.AddUpdateLocksetFunc(Microsoft.Boogie.Type.Bool); this.AddNonCheckedFunc(); this.AddEnableNetworkFunc(); this.AddDisableNetworkFunc(); foreach (var region in this.AC.InstrumentationRegions) { this.InstrumentImplementation(region); } this.AnalyseDomainSpecificLockUsage(); this.InstrumentEntryPointProcedure(); foreach (var region in this.AC.InstrumentationRegions) { this.InstrumentProcedure(region); } if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [LocksetInstrumentation] {0}", this.Timer.Result()); } }
/// <summary> /// Creates an instance of the test class for the given test case. Sends the <see cref="ITestClassConstructionStarting"/> /// and <see cref="ITestClassConstructionFinished"/> messages as appropriate. /// </summary> /// <param name="test">The test</param> /// <param name="testClassType">The type of the test class</param> /// <param name="constructorArguments">The constructor arguments for the test class</param> /// <param name="messageBus">The message bus used to send the test messages</param> /// <param name="timer">The timer used to measure the time taken for construction</param> /// <param name="cancellationTokenSource">The cancellation token source</param> /// <returns></returns> public static object CreateTestClass(this ITest test, Type testClassType, object[] constructorArguments, IMessageBus messageBus, ExecutionTimer timer, CancellationTokenSource cancellationTokenSource) { object testClass = null; if (!messageBus.QueueMessage(new TestClassConstructionStarting(test))) { cancellationTokenSource.Cancel(); } else { try { if (!cancellationTokenSource.IsCancellationRequested) { timer.Aggregate(() => testClass = Activator.CreateInstance(testClassType, constructorArguments)); } } finally { if (!messageBus.QueueMessage(new TestClassConstructionFinished(test))) { cancellationTokenSource.Cancel(); } } } return(testClass); }
/// <summary> /// Disposes the test class instance. Sends the <see cref="ITestClassDisposeStarting"/> and <see cref="ITestClassDisposeFinished"/> /// messages as appropriate. /// </summary> /// <param name="test">The test</param> /// <param name="testClass">The test class instance to be disposed</param> /// <param name="messageBus">The message bus used to send the test messages</param> /// <param name="timer">The timer used to measure the time taken for construction</param> /// <param name="cancellationTokenSource">The cancellation token source</param> public static void DisposeTestClass(this ITest test, object testClass, IMessageBus messageBus, ExecutionTimer timer, CancellationTokenSource cancellationTokenSource) { if (!(testClass is IDisposable disposable)) { return; } if (!messageBus.QueueMessage(new TestClassDisposeStarting(test))) { cancellationTokenSource.Cancel(); } else { try { timer.Aggregate(disposable.Dispose); } finally { if (!messageBus.QueueMessage(new TestClassDisposeFinished(test))) { cancellationTokenSource.Cancel(); } } } }
public void WrapClassCreatesWrappingProxy(ILogger logger, IMessageBroker messageBroker) { var timer = new ExecutionTimer(Stopwatch.StartNew()); var sut = new CastleDynamicProxyFactory(logger, messageBroker, () => timer, () => RuntimePolicy.On); var overrideMeAlternate = new OverrideMeAlternateMethod <TestProxy>(); var protectedOverrideMeAlternate = new ProtectedOverrideMeAlternateMethod <TestProxy>(); var methodInvocations = new List <IAlternateMethod> { overrideMeAlternate, protectedOverrideMeAlternate }; var target = new TestProxy(); var result = sut.WrapClass(target, methodInvocations); result.OverrideMe(); Assert.Equal(1, overrideMeAlternate.HitCount); Assert.Equal(0, protectedOverrideMeAlternate.HitCount); Assert.Equal(0, result.HitCountOverrideMe); Assert.Equal(0, result.HitCountProtectedOverrideMe); Assert.Equal(1, target.HitCountOverrideMe); Assert.Equal(1, target.HitCountProtectedOverrideMe); }
protected override async Task <RunSummary> RunTestClassAsync(ITestClass testClass, IReflectionTypeInfo @class, IEnumerable <ObservationTestCase> testCases) { var timer = new ExecutionTimer(); var specification = Activator.CreateInstance(testClass.Class.ToRuntimeType()) as Specification; if (specification == null) { Aggregator.Add(new InvalidOperationException(String.Format("Test class {0} cannot be static, and must derive from Specification.", testClass.Class.Name))); return(FailedSummary); } Aggregator.Run(specification.OnStart); if (Aggregator.HasExceptions) { return(FailedSummary); } var result = await new ObservationTestClassRunner(specification, testClass, @class, testCases, diagnosticMessageSink, MessageBus, TestCaseOrderer, new ExceptionAggregator(Aggregator), CancellationTokenSource).RunAsync(); Aggregator.Run(specification.OnFinish); var disposable = specification as IDisposable; if (disposable != null) { timer.Aggregate(disposable.Dispose); } return(result); }
public void Run() { if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var impl in this.AC.TopLevelDeclarations.OfType <Implementation>()) { if (this.SkipFromAnalysis(impl)) { continue; } InstrumentationRegion region = new InstrumentationRegion(this.AC, this.EP, impl); this.AC.InstrumentationRegions.Add(region); } this.EP.RebuildCallGraph(this.AC); if (WhoopCommandLineOptions.Get().MeasurePassExecutionTime) { this.Timer.Stop(); Console.WriteLine(" | |------ [InstrumentationRegionsConstructor] {0}", this.Timer.Result()); } }
/// <summary> /// Validates ILoadTest scenario correctness by executing single test iteration /// from ScenarioSetup to ScenarioTearDown on the same thread. /// Exceptions are not handled on purpose to ease problem identification while developing. /// </summary> /// <param name="loadTestScenario">ILoadTestScenario object</param> /// <param name="threadId">TheardId to set in TestContext</param> /// <param name="threadIterationId">ThreadIterationId to set in TestContext</param> /// <param name="globalIterationId">GlobalIterationId to set in TestContext</param> /// <returns>Raw result from single iteration</returns> public static IterationResult Validate(ILoadTestScenario loadTestScenario, int threadId = 0, int threadIterationId = 0, int globalIterationId = 0) { ExecutionTimer timer = new ExecutionTimer(); TestContext testContext = new TestContext(threadId, timer); testContext.Reset(-1, -1); loadTestScenario.ScenarioSetup(testContext); testContext.Reset(threadIterationId, globalIterationId); testContext.Checkpoint(Checkpoint.IterationSetupCheckpointName); loadTestScenario.IterationSetup(testContext); testContext.Checkpoint(Checkpoint.IterationStartCheckpointName); testContext.Start(); loadTestScenario.ExecuteScenario(testContext); testContext.Stop(); testContext.Checkpoint(Checkpoint.IterationEndCheckpointName); testContext.Checkpoint(Checkpoint.IterationTearDownCheckpointName); loadTestScenario.IterationTearDown(testContext); IterationResult result = new IterationResult(testContext); testContext.Reset(-1, -1); loadTestScenario.ScenarioTearDown(testContext); return result; }
/// <summary> /// Runs a thread usage analysis pass. /// </summary> void IPass.Run() { if (ToolCommandLineOptions.Get().VerboseMode) { Output.PrintLine("... ThreadUsageAnalysis"); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.CreateMainThread(); this.IdentifyThreadUsageInThread(this.AC.MainThread); if (ToolCommandLineOptions.Get().SuperVerboseMode&& this.AC.Threads.Count == 0) { Output.PrintLine("..... No child threads detected"); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer.Stop(); Output.PrintLine("..... [{0}]", this.Timer.Result()); } }
/// <summary> /// Runs a lock abstraction pass. /// </summary> void IPass.Run() { if (ToolCommandLineOptions.Get().VerboseMode) { Output.PrintLine("... LockUsageAnalysis"); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } this.IdentifyLockCreationInThread(this.AC.MainThread); if (this.AC.Locks.Count > 0) { this.AlreadyAnalyzedImplementations.Clear(); this.IdentifyLockUsageInThread(this.AC.MainThread); } if (ToolCommandLineOptions.Get().SuperVerboseMode&& this.AC.Locks.Count == 0) { Output.PrintLine("..... No locks detected"); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer.Stop(); Output.PrintLine("..... [{0}]", this.Timer.Result()); } }
public void Run() { if (ToolCommandLineOptions.Get().VerboseMode) { Output.PrintLine("... ThreadRefactoring"); } if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer = new ExecutionTimer(); this.Timer.Start(); } foreach (var thread in this.AC.Threads) { this.ParseAndRenameNestedFunctions(thread, thread.Function, null); if (ToolCommandLineOptions.Get().SuperVerboseMode) { Output.PrintLine("..... Separated call graph of {0}", thread); } } this.CleanUp(); if (ToolCommandLineOptions.Get().MeasureTime) { this.Timer.Stop(); Output.PrintLine("..... [{0}]", this.Timer.Result()); } }
public void ConstructWithNonRunningStopwatch() { var stopwatch = new Stopwatch(); var timer = new ExecutionTimer(stopwatch); Assert.NotNull(timer); Assert.Equal(stopwatch, timer.Stopwatch); Assert.True(timer.Stopwatch.IsRunning); }
public void TimeFunction() { var waitTime = 5; var timer = new ExecutionTimer(Stopwatch.StartNew()); var result = timer.Time(() => Thread.Sleep(waitTime)); Assert.NotNull(result); var failureMessage = result.Duration.ToString() + " not greater than " + waitTime.ToString(); Console.Write(failureMessage); Assert.True(new DateTime().AddTicks(result.Duration.Ticks) >= new DateTime().AddTicks(result.Duration.Ticks).AddMilliseconds(waitTime - 1), failureMessage); //-1 to handle issues with rounding?? }
public void TimeMethod() { var waitTime = 33; var timer = new ExecutionTimer(Stopwatch.StartNew()); var result = timer.Time(() => { Thread.Sleep(waitTime); return "string".ToUpper(); }); Assert.NotNull(result); Assert.True(new DateTime().AddTicks(result.Duration.Ticks) >= new DateTime().AddTicks(result.Duration.Ticks).AddMilliseconds(waitTime)); Assert.Equal("STRING", result.Result); }
private static ExecutionTimer CreateAndStartGlobalExecutionTimer(IDataStore requestStore) { if (requestStore.Contains(Constants.GlobalStopwatchKey) && requestStore.Contains(Constants.GlobalTimerKey)) { return requestStore.Get<ExecutionTimer>(Constants.GlobalTimerKey); } // Create and start global stopwatch var stopwatch = Stopwatch.StartNew(); var executionTimer = new ExecutionTimer(stopwatch); requestStore.Set(Constants.GlobalStopwatchKey, stopwatch); requestStore.Set(Constants.GlobalTimerKey, executionTimer); return executionTimer; }