Example #1
0
        protected static Timings Time(HybridAction action, decimal modifier, int iterations = 100)
        {
            var watch = new Stopwatch();

            // warmup
            action(out var stats);

            var timings = new Timings
            {
                DbTime   = 0,
                CodeTime = 0
            };

            for (var i = 0; i < iterations; i++)
            {
                watch.Restart();
                action(out stats);
                timings.DbTime += stats.QueryDurationInMilliseconds;

                timings.CodeTime += watch.ElapsedMilliseconds - stats.QueryDurationInMilliseconds;
            }

            timings.DbTime   = (long)(timings.DbTime / modifier);
            timings.CodeTime = (long)(timings.CodeTime / modifier);

            Console.WriteLine($"Total db time over {iterations} iterations was {timings.DbTime}.");
            Console.WriteLine($"Total code time over {iterations} iterations was {timings.CodeTime}.");

            return(timings);
        }
Example #2
0
        public async Task <ActionResult <Timings> > PostTimings(Timings todoItem)
        {
            _context.Timings.Add(todoItem);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTimings", new { id = todoItem.Id }, todoItem));
        }
Example #3
0
        public void record_data()
        {
            var spec = new Specification
            {
                name = "Some Name"
            };

            var timings = new Timings();

            timings.Start(spec);
            using (timings.Subject("Fixture.Setup", "Math"))
            {
                using (timings.Subject("Grammar", "Adding"))
                {
                    using (timings.Subject("Fixture.Teardown", "Math"))
                    {
                        Thread.Sleep(100);
                    }
                }
            }

            var records = timings.Finish();

            records.Select(x => x.Subject).ShouldHaveTheSameElementsAs("Some Name", "Math", "Adding", "Math");

            records.Each(x => x.Duration.ShouldBeGreaterThan(0));
        }
Example #4
0
        public SpecResults Execute(Specification specification)
        {
            var plan    = specification.CreatePlan(_library);
            var timings = new Timings();

            timings.Start(specification);

            IExecutionContext execution = null;

            using (timings.Subject("Context", "Creation"))
            {
                execution = _system.CreateContext();
            }

            var context = new SpecContext(specification, timings, new NulloResultObserver(), StopConditions,
                                          execution);

            context.Reporting.As <Reporting>().StartDebugListening();

            var executor = new SynchronousExecutor(context);

            plan.AcceptVisitor(executor);



            execution.Dispose();
            context.Dispose();

            return(context.FinalizeResults(1));
        }
Example #5
0
    /// <summary>
    /// Awake does some maintenance. It maintaines Timings as a singleton.
    /// </summary>
    void Awake()
    {
        DontDestroyOnLoad(gameObject);

        if (instance != null && instance != this)
        {
            Destroy(gameObject);
        }
        else if (SceneManager.GetActiveScene().name == "GameOver" || SceneManager.GetActiveScene().name == "GameWon" || SceneManager.GetActiveScene().name == "Times")
        {
            InitialiseTextObjects();
            DisplayTimes();
            Destroy(gameObject);
        }
        else
        {
            instance = this;

            savedInventory      = null;
            JacksRoomFinished   = false;
            BethsRoomFinished   = false;
            RhysRoomFinished    = false;
            room102KeycardTaken = false;
        }
    }
Example #6
0
 public Branch FindBranch(SyntaxNode expression, out Condition inlineCondition)
 {
     using (new OperationTimer(i => Timings.Update(TimingOperation.FindBranch, i)))
     {
         return(InnerFindBranch(this, expression, out inlineCondition));
     }
 }
Example #7
0
        private void restoreDefaultButton_Click(object sender, EventArgs e)
        {
            Timings defaultTimings = RestoreTimingDefault.defaultTimings();

            this.currentTimings = defaultTimings;
            this.renderTimings();
        }
Example #8
0
        private void SaveTiming(Timing timing)
        {
            var rootTiming = new TimingPoco
            {
                Id                   = timing.Id,
                ParentTimingId       = timing.IsRoot ? (Guid?)null : timing.ParentTiming.Id,
                Name                 = timing.Name,
                StartMilliseconds    = (double)timing.StartMilliseconds,
                DurationMilliseconds = (double)timing.DurationMilliseconds
            };

            Timings.Insert(rootTiming);

            if (timing.HasChildren)
            {
                foreach (var child in timing.Children)
                {
                    SaveTiming(child);
                }
            }

            if (timing.HasCustomTimings)
            {
                foreach (var customTimingsKV in timing.CustomTimings)
                {
                    SaveCustomTimings(timing, customTimingsKV);
                }
            }
        }
Example #9
0
        public SpecResults Execute(Specification specification)
        {
            var plan    = specification.CreatePlan(_library);
            var timings = new Timings();

            _warmup.Wait(1.Minutes());

            timings.Start(specification);

            IExecutionContext execution = null;
            SpecContext       context   = null;

            try
            {
                using (timings.Record("Context", "Creation"))
                {
                    execution = _system.CreateContext();
                }

                context = new SpecContext(specification, timings, new NulloResultObserver(), StopConditions,
                                          execution);

                context.Reporting.As <Reporting>().StartDebugListening();

                SpecExecution.RunAll(context, plan);
            }
            finally
            {
                execution?.Dispose();
                context?.Dispose();
            }


            return(context.FinalizeResults(1));
        }
Example #10
0
        public virtual int DefaultTiming(Timings timing)
        {
            // default for the given timing for this engine.  Can be overridden by individual engines; they should call through to this for any values they are not interested in
            // Note that this will return a default value for the timing is not used by this engine
            switch (timing)
            {
            case Timings.AcceptanceTime:
                return(0);                        // Logical.StandardAcceptanceTime; // note these get updated by GUI - bit tangled at the mo

            case Timings.PostActivation:
                return(100);                        // Logical.PostActivationTime;

            case Timings.LongPress:
                return(1000);

            case Timings.ScanTime:
                return(800);

            case Timings.FirstRepeat:
                return(3600);

            case Timings.SubsequentRepeat:
                return(1800);

            case Timings.DwellSelect:
                return(1500);

            case Timings.CriticalReverse:
                return(1200);

            default:
                Debug.Fail("Unexpected timing in DefaultTiming: " + timing);
                return(1000);
            }
        }
Example #11
0
        public MethodFlowAnalysis Analyze(BlockSyntax body, IEnumerable <SyntaxNode> statements)
        {
            hasConstraints = false;
            assignments.Clear();
            lambdas.Clear();
            using (new OperationTimer(i => Timings.Update(TimingOperation.MethodAnlyzer, i)))
            {
                var tree        = BuildTree(null, null, statements, false);
                var lambdaTrees = new List <Branch>();
                while (lambdas.Count > 0)
                {
                    var lambda = lambdas.Dequeue();
                    if (lambda.Item2.Body is BlockSyntax block)
                    {
                        lambdaTrees.Add(BuildTree(lambda.Item1, null, lambda.Item2.Body.ChildNodes(), true));
                    }
                    else
                    {
                        lambdaTrees.Add(BuildTree(lambda.Item1, null, new[] { lambda.Item2.Body }, true));
                    }
                }
                // This is kinda a hack. The idea is that we probably wanna search the inner most lambda first.
                // But since each lambda contains all the statements of the inner lambdas, we'd match on the outer one first.
                // So reverse the list and start at the bottom.
                lambdaTrees.Reverse();

                var nullAssignments = assignments
                                      .Where(i => i.Value != ValueType.NotNull)
                                      .Select(i => i.Symbol)
                                      .ToList();

                if (body != null)
                {
                    var data = model.AnalyzeDataFlow(body);

                    var variablesThatAreAlwaysNotNull = data.AlwaysAssigned.RemoveAll(i => i is IParameterSymbol || nullAssignments.Any(j => j.Equals(i)));

                    var safeParameters = data.WrittenOutside.Where(i => i.HasNotNullOrCheckNull());

                    return(new MethodFlowAnalysis(
                               mode,
                               model,
                               assignments,
                               variablesThatAreAlwaysNotNull.AddRange(safeParameters),
                               tree,
                               lambdaTrees,
                               hasConstraints,
                               returnStatements));
                }
                return(new MethodFlowAnalysis(
                           mode,
                           model,
                           assignments,
                           ImmutableArray.Create <ISymbol>(),
                           tree,
                           lambdaTrees,
                           hasConstraints,
                           returnStatements));
            }
        }
Example #12
0
        public async Task <IActionResult> PutTimings(long id, Timings todoItem)
        {
            if (id != todoItem.Id)
            {
                return(BadRequest());
            }

            _context.Entry(todoItem).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!TimingsExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #13
0
        /// <summary>
        /// Stops timing an event. Logs an exception if the event wasn't started.
        /// </summary>
        /// <param name="metric"></param>
        /// <returns></returns>
        public Timing StopEvent(Metric metric)
        {
            Timing timing;

            lock (metricsLock)
            {
                if (!inFlightTimings.TryGetValue(metric, out timing))
                {
                    LogError_Locked(metric, "Trying to stop event that has not been started");
                    return(new Timing());
                }
                inFlightTimings.Remove(metric);
                timing.Stop(CurrentTime);

                if (IsEnabled)
                {
                    List <IMetricsTiming> list;
                    if (!Timings.TryGetValue(metric, out list))
                    {
                        list            = new List <IMetricsTiming>();
                        Timings[metric] = list;
                    }
                    list.Add(timing);
                }
            }
            return(timing);
        }
Example #14
0
 public void CalculateMissedCount()
 {
     Timings.Sum(number => { if (number == -1)
                             {
                                 MissedCount++;
                             }
                             return(0); });
 }
Example #15
0
        public void SelectValueByText(string text, Timings timings = null)
        {
            Click();
            var controlList = portal.FindList().Of <Label>("MenuItem").By("Menu");

            controlList.IsPresent.Wait().That(x => x.AssertEqualTo(true), timings);
            controlList.First(x => x.Text.Get() == text).Click();
        }
 private void UpdatePivots()
 {
     Books.Navigate(typeof(Books), lastSelectedIndex - 1);
     Handouts.Navigate(typeof(Handout), lastSelectedIndex - 1);
     TeacherList.Navigate(typeof(Teachers), lastSelectedIndex - 1);
     TestList.Navigate(typeof(Tests), lastSelectedIndex - 1);
     Timings.Navigate(typeof(Timings), lastSelectedIndex - 1);
 }
Example #17
0
 public override int DefaultTiming(Timings timing)
 {
     switch (timing)
     {
     case Timings.ScanTime:
         return(350);
     }
     return(base.DefaultTiming(timing));
 }
 private void UpdateStep(Timings UpdateTiming)
 {
     if (Timing == UpdateTiming &&
         stepsSincePublication++ % skipFrames == 0)
     {
         //     Debug.Log("Frame No. " + Time.frameCount);
         StartPublication(EventArgs.Empty);
     }
 }
Example #19
0
        private bool loadFileTimings()
        {
            bool loadSave    = false;
            bool invalidData = false;

            if (this.defaultFileName != null && this.defaultFileName.Length > 0)
            {
                try
                {
                    string regexSearch   = new string(Path.GetInvalidPathChars());
                    Regex  r             = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
                    String validFileName = r.Replace(this.defaultFileName, "");

                    String fullPath = Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), validFileName);
                    fullPath = Path.ChangeExtension(fullPath, "bst");

                    if (File.Exists(fullPath))
                    {
                        using (FileStream fs = new FileStream(fullPath, FileMode.Open))
                        {
                            using (BinaryReader binReader = new BinaryReader(fs))
                            {
                                long fileSize   = binReader.BaseStream.Length;
                                int  timingSize = Marshal.SizeOf(new Timings());
                                if (fileSize == timingSize)
                                {
                                    byte[] readedBytes = binReader.ReadBytes(timingSize);
                                    this.currentTimings = this.timinsgFromBytes(readedBytes);
                                }
                                else
                                {
                                    invalidData = true;
                                }
                                binReader.Close();
                            }
                            fs.Close();
                        }
                        loadSave = true;
                    }
                    else
                    {
                        loadSave = false;
                    }
                }
                catch
                {
                    loadSave = false;
                    MessageBox.Show("Unknown Error\n\nabort loading", "Loading Error");
                }
            }
            if (invalidData)
            {
                MessageBox.Show("corrupt file detected\n\nabort loading", "Loading Error");
            }

            return(loadSave);
        }
Example #20
0
        public void SelectValueByValue(object value, Timings timings = null)
        {
            Click();
            var items       = GetReactProp <JArray>("items");
            var index       = items.ToList().FindIndex(x => ElementMatchToValue(value, x));
            var controlList = portal.FindList().Of <Label>("MenuItem").By("Menu");

            controlList[index].IsPresent.Wait().That(x => x.AssertEqualTo(true), timings);
            controlList[index].Click();
        }
Example #21
0
 public float AverageTimings()
 {
     return(MissedCount < Timings.Length ?
            Timings.Sum(number => { if (number == -1)
                                    {
                                        return 0;
                                    }
                                    return number; }) / (Timings.Length - MissedCount)
         : 0.0f);
 }
Example #22
0
 public void InputTextAndSelectFirst(string inputText, Timings timings = null)
 {
     InputText(inputText);
     DoWithItems((x, y) => new Label(x, y), items =>
     {
         items.Count.Wait().That(x => x.AssertGreaterThan(0), timings);
         var result = items.First();
         result?.Click();
     }, timings);
 }
Example #23
0
 public void InputTextAndSelectSingle(string inputText, Timings timings = null)
 {
     Click();
     InputText(inputText);
     DoWithItems((x, y) => new Label(x, y), items =>
     {
         items.Count.Wait().That(x => x.AssertEqualTo(1), timings);
         var result = items.First();
         result?.Click();
     });
 }
Example #24
0
        public void Complete(string name, bool store, bool display = false)
        {
            Sw.Stop();
            var ticks = Sw.ElapsedTicks;
            var ns    = 1000000000.0 * ticks / Stopwatch.Frequency;
            var ms    = ns / 1000000.0;

            if (store)
            {
                Timings timings;
                if (_timings.TryGetValue(name, out timings))
                {
                    timings.Total += ms;
                    timings.Values.Add((int)ns);
                    timings.Events++;
                    timings.Average = (timings.Total / timings.Events);
                    if (ms > timings.Max)
                    {
                        timings.Max     = ms;
                        timings.MaxTick = Session.Tick;
                    }
                    if (ms < timings.Min || timings.Min <= 0)
                    {
                        timings.Min = ms;
                    }
                }
                else
                {
                    timings        = new Timings();
                    timings.Total += ms;
                    timings.Values.Add((int)ns);
                    timings.Events++;
                    timings.Average = ms;
                    timings.Max     = ms;
                    timings.MaxTick = Session.Tick;
                    timings.Min     = ms;
                    _timings[name]  = timings;
                }
            }
            Sw.Reset();
            if (display)
            {
                var message = $"[{name}] ms:{(float)ms} last-ms:{(float)_last}";
                _last = ms;
                if (_time)
                {
                    Log.LineShortDate(message);
                }
                else
                {
                    Log.CleanLine(message);
                }
            }
        }
        private static int GetTotalTime(Timings timings)
        {
            int total = 0;

            total += timings.blocked;
            total += timings.dns;
            total += timings.connect;
            total += timings.send;
            total += timings.wait;
            total += timings.receive;
            return(total);
        }
        public void InputTextAndSelectFirst(string inputText, Timings timings = null)
        {
            Click();
            InputText(inputText);
            GetItemsAs((x, y) => new Label(x, y)).Count.Wait().That(x => x.AssertGreaterThan(0), timings);
            var result = GetItemsAs((x, y) => new Label(x, y)).First();

            if (result != null)
            {
                SelectByIndex(0);
            }
        }
Example #27
0
        public SpecContext(Specification specification, Timings timings, IResultObserver observer, StopConditions stopConditions, IExecutionContext execution)
        {
            Counts          = new Counts();
            Specification   = specification;
            _resultObserver = observer;
            _execution      = execution;
            StopConditions  = stopConditions;

            _timings = timings ?? new Timings();

            Reporting = new Reporting();
        }
 public IActionResult UpdateTimings(Timings timings)
 {
     try
     {
         int userId = _session.GetInt32("UserID").Value;
         _businessService.UpdateBusinessTimings(userId, timings);
         return(Json("Updated Successfully. Thank You"));
     }
     catch (Exception e)
     {
         return(Json("Something went wrong please try later" + e));
     }
 }
Example #29
0
        private Timing LoadTiming(Guid id)
        {
            var timingPoco = Timings.FindOne(Query <TimingPoco> .EQ(poco => poco.Id, id));
            var timing     = TimingPocoToTiming(timingPoco);

            if (timing != null)
            {
                timing.Children      = LoadChildrenTimings(timing.Id);
                timing.CustomTimings = LoadCustomTimings(timing.Id);
            }

            return(timing);
        }
Example #30
0
        byte[] getBytesFromTimings(Timings str)
        {
            int size = Marshal.SizeOf(str);

            byte[] arr = new byte[size];
            IntPtr ptr = Marshal.AllocHGlobal(size);

            Marshal.StructureToPtr(str, ptr, true);
            Marshal.Copy(ptr, arr, 0, size);
            Marshal.FreeHGlobal(ptr);

            return(arr);
        }
Example #31
0
 public void AddToTimings(Timings timings)
 {
     base.AddObject("Timings", timings);
 }
Example #32
0
 public static Timings CreateTimings(global::System.Guid timingsID, string timingTypID)
 {
     Timings timings = new Timings();
     timings.TimingsID = timingsID;
     timings.TimingTypID = timingTypID;
     return timings;
 }