public void Start() { switch (state) { case State.Stopped: { state = State.Running; stopWatch.Start(); } break; case State.Running: { } break; default: { Contract.Assert(false); break; } } }
private int RunOneAnalysis(int id, string[] args, string selectedMethods) { var watch = new CustomStopwatch(); watch.Start(); var idStr = string.Format("[{0}] ", id); try { Console.WriteLine(idStr + "Running with option = {0}", selectedMethods); var proc = SetupProcessInfo(GetExecutable(), args, selectedMethods); using (var exe = Process.Start(proc)) { Task.Factory.StartNew( () => { while (!exe.HasExited) { var lineErr = exe.StandardError.ReadLine(); Console.WriteLine(idStr + lineErr); } var lineOut = exe.StandardError.ReadToEnd(); Console.Write(idStr + lineOut); }); // Reads the standard output string line; while (!exe.HasExited) { line = exe.StandardOutput.ReadLine(); Console.WriteLine(idStr + line); } line = exe.StandardOutput.ReadToEnd(); Console.WriteLine(idStr + line); return(exe.ExitCode); } } catch { Console.WriteLine(idStr + "failed to start the process"); return(-1); } finally { Console.WriteLine(idStr + "Analysis of {0} took {1}", selectedMethods, watch.Elapsed); // nothing? } }
/// <param name="seconds"> The timeout in seconds</param> public TimeOutChecker(int seconds, CancellationToken cancellationToken, bool start = true) { Contract.Requires(seconds >= 0); stopWatch = new CustomStopwatch(); totalElapsed = new TimeSpan(); if (start) { stopWatch.Start(); state = State.Running; } else { state = State.Stopped; } timeout = seconds; this.cancellationToken = cancellationToken; exception = null; }
static void Main(string[] args) { var start = DateTime.Now; var stopWatch = new CustomStopwatch(); stopWatch.Start(); var tasks = new Task <int> [args.Length]; var cmds = new string[tasks.Length]; times = new TimeSpan[tasks.Length]; for (var i = 0; i < args.Length; i++) { cmds[i] = args[i]; } Console.WriteLine("We start the analyses"); for (var i = 0; i < tasks.Length; i++) { var clousotArgs = new List <string>(); clousotArgs.Add(cmds[i]); Console.WriteLine("call: " + i); var local = i; // without it we get the wrong parameter!!!!!!!! tasks[i] = new Task <int>(() => CallClousotEXE(local, clousotArgs.ToArray())); tasks[i].Start(); } Console.WriteLine("We wait"); Task.WaitAll(tasks); for (var i = 0; i < tasks.Length; i++) { Console.WriteLine("Time for {0} was : {1}", i, times[i]); } Console.WriteLine("we are done (in {0})! Press a key", stopWatch.Elapsed); Console.ReadKey(); }
/// <summary> /// Buckets output /// </summary> public void RunWithBuckets(string[] args) { Contract.Requires(args != null); args = RemoveArgs(args); // To make cccheck.exe happy var watch = new CustomStopwatch(); watch.Start(); var executor = new BucketExecutor(); // var id = 0; var temp = new ConcurrentBag <IEnumerable <int> >(); // foreach(var bucket in this.GenerateDisjointBuckets()) Parallel.ForEach( this.GenerateDisjointBuckets(), bucket => { //PrintBucket(watch, bucket); temp.Add(bucket); // executor.AddJob(() => RunOneAnalysis(id++, args, ToSelectArgument(bucket))); }); var array = temp.ToArray(); Console.WriteLine("Eventually we inferred {0} buckets", array.Count()); foreach (var b in array) { PrintBucket(watch, b); } //executor.DoAllTheRemainingJobs(); //executor.WaitForStillActiveJobs(); }
public bool TryInferConditions(ProofObligation obl, ICodeFixesManager codefixesManager, out InferredConditions preConditions) { var watch = new CustomStopwatch(); watch.Start(); var result = inner.TryInferConditions(obl, codefixesManager, out preConditions); watch.Stop(); inferenceTime += watch.Elapsed; if (preConditions == null) { return(false); } if (result) { inferred += preConditions.Count(); } return(result); }
private IEnumerable <IFixpointInfo <APC, INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> > > FixpointInfo() { if (fixpointInfo_List == null) { fixpointInfo_List = new List <IFixpointInfo <APC, INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> > >(); } var cached_Count = fixpointInfo_List.Count; for (var i = 1; i < this.optionsList.Count; i++) { var result = null as IFixpointInfo <APC, INumericalAbstractDomain <BoxedVariable <Variable>, BoxedExpression> >; if (cached_Count > 0 && i <= cached_Count) { result = fixpointInfo_List[i - 1]; } else { var opt = this.optionsList[i]; try { #if DEBUG var stopWatch = new CustomStopwatch(); stopWatch.Start(); Console.WriteLine("[NUMERICAL] Running a refined analysis"); #endif if (this.Options.LogOptions.ShowPhases) { Console.WriteLine("===== Running a refined analysis"); } string why; if (!this.MethodDriver.AdditionalSyntacticInformation.Renamings.TooManyRenamingsForRefinedAnalysis(!this.Options.LogOptions.IsAdaptiveAnalysis, out why)) { var run = AnalysisWrapper.RunTheAnalysis(this.MethodName, opt.Type, this.MethodDriver, opt, (APC pc) => false, Controller == null || !Controller.HasReachedEnd ? null : Controller) as NumericalAnalysis <Options>; result = run.fixpointInfo; } else { #if DEBUG var methodName = this.DecoderForMetaData.Name(this.MethodDriver.CurrentMethod); Console.WriteLine("[REFINED ANALYSIS] Skipping refined analysis as the method {0} contains too many renamings ({1}). To force the more precise analysis add the option -adaptive=false", methodName, why); #endif result = null; } #if DEBUG if (this.Options.LogOptions.ShowPhases) { Console.WriteLine(" Refined analysis done. Elapsed {0}", stopWatch.Elapsed); } #endif } catch (TimeoutExceptionFixpointComputation) { #if DEBUG Console.WriteLine("on demand fixpoint computation timed out!"); #endif } // Cache the fixpoint this.fixpointInfo_List.Add(result); } if (result != null) { yield return(result); } } }