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); }
private void FlagStale(Accu accu) { accu.Fresh = false; foreach (var child in accu.Children) { FlagStale(child); } }
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")); }
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); }
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); } }
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)); }
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; }
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 })); }
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(); } }
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; }
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)); }
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)); }
public DefaultProfiler() { _current = _root; }
public AccuControler(OnPowerChanged callbackOnPowerChanged) { this.callbackOnPowerChanged = callbackOnPowerChanged; this.accu = new Accu(12); }