Esempio n. 1
0
        public double Pop()
        {
            double microSecs = ((_watch.ElapsedTicks - _current.StartTicks) / (double)Stopwatch.Frequency) * 1000000.0;

            _current.Frames++;
            _current.Last = microSecs;

            //PEAK
            if (microSecs > _current.PeakTreshold)
            {
                _current.Peak         = microSecs;
                _current.PeakTreshold = 2f * microSecs;
            }
            _current.PeakTreshold *= 0.95f;

            //AVERAGE
            if (_current.Frames > AVG_SAMPLE_COUNT)
            {
                _current.Average *= AVG_SAMPLE_COUNT / (float)(AVG_SAMPLE_COUNT + 1);
            }
            _current.Average += microSecs;

            //move up the tree!
            _current = _current.Parent;
            if (_current == _root)
            {
                _watch.Stop();
            }

            return(microSecs);
        }
Esempio n. 2
0
 private void FlagStale(Accu accu)
 {
     accu.Fresh = false;
     foreach (var child in accu.Children)
     {
         FlagStale(child);
     }
 }
Esempio n. 3
0
        public IActionResult AccuView(int id)
        {
            var selectedAccu = new Accu().GetAccuById(id);

            if (selectedAccu != null)
            {
                return(View(selectedAccu));
            }
            ModelState.AddModelError("", "Something went wrong while trying to connect to the database ");
            return(RedirectToAction("Index", "Home"));
        }
Esempio n. 4
0
        private Accu GetAccu(string tag)
        {
            Accu ac = null;

            if (_accus.ContainsKey(tag))
            {
                ac = _accus[tag];
            }
            else
            {
                ac = _accus[tag] = new Accu(tag);
            }

            FlagStale(ac);
            return(ac);
        }
Esempio n. 5
0
 private void CollectRecords(Accu node, List <ProfileRecord> records, int depth)
 {
     records.Add(new ProfileRecord()
     {
         Depth   = depth,
         Fresh   = node.Fresh,
         Tag     = node.Tag,
         Last    = node.Last,
         Peak    = node.Peak,
         Average = node.Average / Math.Min(node.Frames, AVG_SAMPLE_COUNT)
     });
     foreach (var child in node.Children)
     {
         CollectRecords(child, records, depth + 1);
     }
 }
Esempio n. 6
0
        public ActionResult UpdateAccu(AccuViewModel model)
        {
            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var accu = new Accu(model.Id, model.Name, model.CreatorId, model.Specs);

            if (new Accu().UpdateAccu(accu))
            {
                return(RedirectToAction("AccuView", new { id = model.Id }));
            }

            ModelState.AddModelError("", "Something went wrong while trying to connect to the database ");
            return(View(model));
        }
Esempio n. 7
0
        public void Push(string tag)
        {
            if (_current == _root)
            {
                _root.Children.Clear();
                _watch.Start();
            }

            string path = _current.Tag + "/" + tag;

            Accu ac = GetAccu(path);

            ac.Parent = _current;
            _current.Children.Add(ac);
            _current      = ac;
            ac.Fresh      = true;
            ac.StartTicks = _watch.ElapsedTicks;
        }
Esempio n. 8
0
        public IActionResult UpdateAccu(int id)
        {
            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }
            var selectedAccu = new Accu().GetAccuById(id);

            if (selectedAccu != null)
            {
                var model = new AccuViewModel()
                {
                    Id          = id, Name = selectedAccu.Name, Specs = selectedAccu.Specs, CreatorId = selectedAccu.Creator.Id,
                    CreatorName = selectedAccu.Creator.Username
                };
                return(View(model));
            }
            ModelState.AddModelError("", "Something went wrong while trying to connect to the database ");
            return(RedirectToAction("AccuView", new { id = id }));
        }
Esempio n. 9
0
        public void End(string tag)
        {
            Accu   ac       = _open[tag];
            double microSec = ((_watch.ElapsedTicks - ac.StartTicks) / (double)Stopwatch.Frequency) * 1000000.0;

            if (microSec > ac.PeakTreshold)
            {
                ac.Peak         = microSec;
                ac.PeakTreshold = 2f * microSec;
            }
            ac.PeakTreshold *= 0.95f;

            ac.Average *= 0.99f;
            ac.Average += microSec;

            _open.Remove(tag);
            if (_open.Count == 0)
            {
                _watch.Stop();
            }
        }
Esempio n. 10
0
        public void Begin(string tag)
        {
            Accu ac = null;

            if (_accus.ContainsKey(tag))
            {
                ac = _accus[tag];
            }
            else
            {
                ac          = new Accu();
                _accus[tag] = ac;
            }

            if (_open.Count == 0)
            {
                _watch.Start();
            }

            ac.StartTicks = _watch.ElapsedTicks;
            _open[tag]    = ac;
        }
Esempio n. 11
0
        public IActionResult CreateOrder()
        {
            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var clients = new Client().GetAllClients();
            var accus   = new Accu().GetAllAccus();

            if (clients == null || accus == null)
            {
                ModelState.AddModelError("", "Something went wrong while trying to connect to the database ");
                return(RedirectToAction("Index", "Home"));
            }

            var model = new OrderViewModel {
                Accus = accus, Clients = clients
            };

            return(View(model));
        }
Esempio n. 12
0
        public ActionResult UpdateOrder(OrderViewModel model)
        {
            if (!User.IsInRole("Admin"))
            {
                return(RedirectToAction("Index", "Home"));
            }

            var oldOrder = new Order().GetOrderById(model.Id);

            var client  = new Client().GetClientById(model.ClientId);
            var accu    = new Accu().GetAccuById(model.AccuId);
            var creator = oldOrder.Creator;

            var order = new Order(oldOrder.Id, client, model.Location, creator, accu, model.Info,
                                  model.Done);

            if (new Order().UpdateOrder(order))
            {
                return(RedirectToAction("OrderView", new { id = model.Id }));
            }

            ModelState.AddModelError("", "Something went wrong while trying to connect to the database ");
            return(View(model));
        }
Esempio n. 13
0
 public DefaultProfiler()
 {
     _current = _root;
 }
Esempio n. 14
0
 public AccuControler(OnPowerChanged callbackOnPowerChanged)
 {
     this.callbackOnPowerChanged = callbackOnPowerChanged;
     this.accu = new Accu(12);
 }