Exemplo n.º 1
0
        // colToGroup is an index from aNewColumnOrder.
        public GroupedTable(Database.Table table, ArrayRange range, int colToGroup, SortOrder sortOrder, FnCreateGroupTable subTable)
            : base(table.Schema)
        {
            m_table = table;
            if (m_table is ExpandTable)
            {
                m_expandTable = (ExpandTable)m_table;
            }
            m_Meta = m_table.GetMetaData();
            m_GroupedColumnFirst = 0;
            m_GroupedColumnLast  = 0;
            m_ColumnOrder        = new int[] { colToGroup };// colGroupOrder;
            m_SortOrder          = new SortOrder[1] {
                sortOrder
            };
            m_createGroupTable = subTable;

            using (Profiling.GetMarker(Profiling.MarkerId.GroupedTable).Auto())
            {
                var col     = m_table.GetColumnByIndex(colToGroup);
                var metaCol = m_Meta.GetColumnByIndex(colToGroup);
                if (metaCol.DefaultGroupAlgorithm != null)
                {
                    m_GroupCollection = metaCol.DefaultGroupAlgorithm.Group(col, range, sortOrder);
                }
                else
                {
                    throw new Exception("Trying to group a column without grouping algorithm. Column '" + metaCol.Name + "' from table '" + m_table.GetName() + "'");
                }
                InitializeFromGroupCollection(col, colToGroup);
            }
        }
Exemplo n.º 2
0
        private async Task <RowSet> ExecuteStatement(IStatement statement)
        {
            using (new TraceProfileContext("ExecuteQuery", "Execute query"))
            {
                RowSet rowSet          = null;
                var    numberOfAttempt = 0;
                do
                {
                    try
                    {
                        rowSet = await _session.ExecuteAsync(statement);

                        return(rowSet);
                    }
                    catch (NoHostAvailableException noHostAvailableEx)
                    {
                        ExceptionPolicy.HandleException(noHostAvailableEx, "logonly");
                        await Task.Delay(RetrySetting.DelayInMs);

                        numberOfAttempt++;
                        Profiling.Trace("Number of attempt(s) " + (numberOfAttempt).ToString());
                        if (numberOfAttempt > RetrySetting.NumberOfRetry)
                        {
                            throw noHostAvailableEx;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                } while (numberOfAttempt <= RetrySetting.NumberOfRetry);

                return(rowSet);
            }
        }
        public async Task <Dictionary <string, string> > GetAllAsync()
        {
            try
            {
                using (new ProfileContext("ConsulConfigurationStore.GetAll"))
                {
                    var formatedKey = "/";
                    var dataSet     = await ConsulClientFactory.Instance.KV.List(formatedKey);

                    await LogRQRS(formatedKey, dataSet, _applicationName, "get_all_async");

                    var response = ParseResponse(dataSet);
                    if (response != null)
                    {
                        Profiling.Trace($"Key: {response.Count}");
                    }
                    return(response);
                }
            }


            catch (Exception ex)
            {
                Platform.Common.ExceptionPolicy.HandleException(ex, Constants.DefaultPolicy);
            }

            throw new ConfigurationException("Could not connect to consul", "100", System.Net.HttpStatusCode.InternalServerError);
        }
        public string Get(string scope, string application, string section, string key)
        {
            using (new ProfileContext("ConsulConfigurationStore.Get"))
            {
                var formatedKey = KeyMaker.ConstructKey(scope, application, section, key).ToLowerInvariant();

                Profiling.Trace($"Key: {formatedKey}");

                QueryResult <KVPair> response = null;

                var waitHandle = new ManualResetEvent(false);

                Task.Factory.StartNew(async() =>
                {
                    try
                    {
                        response = await ConsulClientFactory.Instance.KV.Get(formatedKey);
                        await LogRQRS(formatedKey, response, application, "get");
                    }
                    finally
                    {
                        waitHandle.Set();
                    }
                });
                waitHandle.WaitOne();

                return(ParseResponse(response));
            }
        }
Exemplo n.º 5
0
        protected virtual long[] GetSortIndex(System.Collections.Generic.IComparer <DataT> comparer, ArrayRange indices, bool relativeIndex)
        {
            using (Profiling.GetMarker(Profiling.MarkerId.Sort).Auto())
            {
                Update();
                long    count = indices.Count;
                DataT[] keys  = new DataT[count];


                //create index array
                long[] index = new long[count];
                if (relativeIndex)
                {
                    for (long i = 0; i != count; ++i)
                    {
                        index[i] = i;
                        keys[i]  = GetRowValue(indices[i]);
                    }
                }
                else
                {
                    for (long i = 0; i != count; ++i)
                    {
                        index[i] = indices[i];
                        keys[i]  = GetRowValue(indices[i]);
                    }
                }

                using (Profiling.GetMarker(Profiling.MarkerId.ArraySort).Auto())
                {
                    System.Array.Sort(keys, index, comparer);
                }
                return(index);
            }
        }
Exemplo n.º 6
0
 private void OnClearCacheTimerTick(object sender, EventArgs e)
 {
     try
     {
         if (!base.IsDisposed && (this.fontPreviewRenderCache != null))
         {
             using (Profiling.UseEnter("Clearing the font preview cache"))
             {
                 Dictionary <TupleStruct <string, float, PaintDotNet.UI.Media.Brush>, PlacedBitmap> fontPreviewRenderCache = this.fontPreviewRenderCache;
                 lock (fontPreviewRenderCache)
                 {
                     this.fontPreviewRenderCache.Clear();
                 }
             }
         }
     }
     catch (Exception)
     {
     }
     finally
     {
         try
         {
             DisposableUtil.Free <System.Windows.Forms.Timer>(ref this.clearCacheTimer);
         }
         catch (Exception)
         {
         }
     }
 }
Exemplo n.º 7
0
 protected virtual void OnGUI(int elementIndex)
 {
     using (Profiling.GetMarker(Profiling.MarkerId.MemoryProfiler).Auto())
     {
         try
         {
             using (new Service <IDebugContextService> .ScopeService(new DebugContextService()))
             {
                 var rect = m_VisualElements[elementIndex].contentRect;
                 if (float.IsNaN(rect.width) || float.IsNaN(rect.height))
                 {
                     rect = new Rect(0, 0, 1, 1);
                 }
                 m_VisualElementsOnGUICalls[elementIndex](rect);
             }
         }
         catch (ExitGUIException)
         {
             throw;
         }
         catch (Exception e)
         {
             throw new Exception(DebugUtility.GetExceptionHelpMessage(e));
         }
     }
 }
Exemplo n.º 8
0
            void SetSnapshot(DataRenderer dataRenderer, PackedMemorySnapshot snapshot)
            {
                if (snapshot == null)
                {
                    m_RawSnapshot   = null;
                    m_RawSchema     = null;
                    SchemaToDisplay = null;
                    UpdateTableSelectionNames();
                    return;
                }

                m_RawSnapshot = snapshot;

                ProgressBarDisplay.ShowBar(string.Format("Opening snapshot: {0}", System.IO.Path.GetFileNameWithoutExtension(snapshot.filePath)));

                var cachedSnapshot = new CachedSnapshot(snapshot);

                using (Profiling.GetMarker(Profiling.MarkerId.CrawlManagedData).Auto())
                {
                    var crawling = Crawler.Crawl(cachedSnapshot);
                    crawling.MoveNext(); //start execution

                    var   status          = crawling.Current as EnumerationStatus;
                    float progressPerStep = 1.0f / status.StepCount;
                    while (crawling.MoveNext())
                    {
                        ProgressBarDisplay.UpdateProgress(status.CurrentStep * progressPerStep, status.StepStatus);
                    }
                }
                ProgressBarDisplay.ClearBar();

                m_RawSchema = new RawSchema();
                m_RawSchema.SetupSchema(cachedSnapshot, dataRenderer);

                SchemaToDisplay = m_RawSchema;
                if (k_DefaultViewFilePath.Length > 0)
                {
                    using (ScopeDebugContext.Func(() => { return("File '" + k_DefaultViewFilePath + "'"); }))
                    {
                        Database.View.ViewSchema.Builder builder = null;
                        using (Profiling.GetMarker(Profiling.MarkerId.LoadViewDefinitionFile).Auto())
                        {
                            builder = Database.View.ViewSchema.Builder.LoadFromXMLFile(k_DefaultViewFilePath);
                        }
                        if (builder != null)
                        {
                            using (Profiling.GetMarker(Profiling.MarkerId.BuildViewDefinitionFile).Auto())
                            {
                                ViewSchema = builder.Build(m_RawSchema);
                            }
                            if (ViewSchema != null)
                            {
                                SchemaToDisplay = ViewSchema;
                            }
                        }
                    }
                }

                UpdateTableSelectionNames();
            }
Exemplo n.º 9
0
        private void debugTreeView_SelectionChanged(object sender, EventArgs e)
        {
            // Color the value according to profiling times.
            if (!MyExecutionBlock.IsProfiling)
            {
                return;
            }

            TreeNodeAdv selectedTreeNode = GetSelectedTreeNode();

            if (selectedTreeNode == null)
            {
                return;
            }

            // Get the relevant children of the current node.
            List <MyDebugNode> children = selectedTreeNode.Children
                                          .Select(child => child.Tag as MyDebugNode)
                                          .Where(childDebugNode => childDebugNode != null && childDebugNode.ProfilerTime != null)
                                          .ToList();

            // Calculate total time of the individual components.
            double totalTime = children.Sum(childDebugNode => childDebugNode.ProfilerTime.Value.TotalMilliseconds);

            // Calculate the colors of the children nodes.
            foreach (MyDebugNode debugNodeChild in children)
            {
                double factor = debugNodeChild.ProfilerTime.Value.TotalMilliseconds / totalTime;

                debugNodeChild.BackgroundColor = Profiling.ItemColor(factor);
            }
        }
Exemplo n.º 10
0
 protected override IComparable GroupTyped(ColumnTyped <DataT> sourceColumn, ArrayRange sourceIndices)
 {
     using (Profiling.GetMarker(Profiling.MarkerId.MergeMedian).Auto())
     {
         long    count = sourceIndices.indexCount;
         DataT[] d     = new DataT[count];
         int     i     = 0;
         foreach (var v in sourceColumn.VisitRows(sourceIndices))
         {
             d[i] = v;
             ++i;
         }
         Array.Sort(d, Comparer.Ascending <DataT>());
         DataT median;
         long  mid = count / 2;
         if (count % 2 == 0)
         {
             median = math.Div(math.Add(d[mid - 1], d[mid]), math.Make(2));
         }
         else
         {
             median = d[mid];
         }
         return(median);
     }
 }
Exemplo n.º 11
0
        public GroupedTable(Database.Table table, ArrayRange range, int colToGroupFirst, int colToGroupLast, int[] colGroupOrder, SortOrder[] sortOrder)
            : base(table.Schema)
        {
            m_table = table;
            if (m_table is ExpandTable)
            {
                m_expandTable = (ExpandTable)m_table;
            }
            m_Meta = m_table.GetMetaData();
            m_GroupedColumnFirst = colToGroupFirst;
            m_GroupedColumnLast  = colToGroupLast;
            m_ColumnOrder        = colGroupOrder;
            m_SortOrder          = sortOrder;

            int sourceGroupedColumnIndex = m_ColumnOrder[colToGroupFirst];

            using (Profiling.GetMarker(Profiling.MarkerId.GroupedTable).Auto())
            {
                var col     = m_table.GetColumnByIndex(sourceGroupedColumnIndex);
                var metaCol = m_Meta.GetColumnByIndex(sourceGroupedColumnIndex);
                if (metaCol.DefaultGroupAlgorithm != null)
                {
                    m_GroupCollection = metaCol.DefaultGroupAlgorithm.Group(col, range, m_SortOrder[colToGroupFirst]);
                }
                else
                {
                    throw new Exception("Trying to group a column without grouping algorithm. Column '" + metaCol.Name + "' from table '" + m_table.GetName() + "'");
                }
                InitializeFromGroupCollection(col, sourceGroupedColumnIndex);
            }
        }
Exemplo n.º 12
0
        public void Should_15_handle_http_get()
        {
            Profiling.Stamp("Creating HttpProxyClientStream...");
            var cli = new Http.HttpProxyClientStream("localhost", _port).Track(this);

            Profiling.Stamp("Creating HttpProxyClientStream TestConnection...");
            TestConnction(cli, Host);
        }
Exemplo n.º 13
0
 public void PopulateEffects()
 {
     using (Profiling.UseEnter())
     {
         this.adjustmentsMenu.PopulateEffects();
         this.effectsMenu.PopulateEffects();
     }
 }
Exemplo n.º 14
0
        public ActionResult Register(RegisterVM registerVM)
        {
            var person = new Person
            {
                NIK       = registerVM.NIK,
                FirstName = registerVM.FirstName,
                LastName  = registerVM.LastName,
                Phone     = registerVM.Phone,
                BirthDate = registerVM.BirthDate,
                Salary    = registerVM.Salary,
                Email     = registerVM.Email
            };

            myContext.Persons.Add(person); //simpan ke table
            myContext.SaveChanges();


            var account = new Account
            {
                NIK      = registerVM.NIK,
                Password = Hashing.HashPassword(registerVM.Password)
            };

            myContext.Accounts.Add(account);
            myContext.SaveChanges();

            var education = new Education
            {
                GPA          = registerVM.GPA,
                Degree       = registerVM.Degree,
                UniversityId = registerVM.UniversityId
            };

            myContext.Educations.Add(education);
            myContext.SaveChanges();

            var profiling = new Profiling
            {
                NIK         = registerVM.NIK,
                EducationId = education.Id
            };

            myContext.Profilings.Add(profiling);
            myContext.SaveChanges();

            var accountRole = new AccountRole
            {
                RoleId    = 2,
                AccountId = registerVM.NIK
            };

            myContext.AccountRoles.Add(accountRole);
            myContext.SaveChanges();

            return(Ok(new { status = HttpStatusCode.OK, message = "Registrasi Berhasil" }));
        }
Exemplo n.º 15
0
 public static string Get(string key)
 {
     using (new ProfileContext("LocalConfigurationRepository.Get"))
     {
         Profiling.Trace($"Key: {key}");
         string value  = string.Empty;
         var    result = _kvStorage.TryGetValue(key, out value) ? value : string.Empty;
         return(result);
     }
 }
Exemplo n.º 16
0
 public void OpenTable(Database.TableReference tableRef, Database.Table table)
 {
     Profiling.StartProfiling("Profile_OpenTable_" + table.GetName());
     CloseCurrentTable();
     m_CurrentTableLink         = tableRef;
     CurrentTableIndex          = m_UIState.CurrentMode.GetTableIndex(table);
     m_Spreadsheet              = new UI.DatabaseSpreadsheet(m_UIState.FormattingOptions, table, this);
     m_Spreadsheet.onClickLink += OnSpreadsheetClick;
     m_EventListener.OnRepaint();
 }
Exemplo n.º 17
0
        public void BaseClean()
        {
            Console.WriteLine("BaseTestCleanup...");

            Profiling.Stamp(TraceCategory.Test, "BaseClean");
            Explode();

            // You can disable this in general and enable during fine object lifecycle profiling
            // this is safe, because ZZ_Clean test will wait for all tests at unce
            // WaitForObjects();
        }
Exemplo n.º 18
0
 protected override IComparable GroupTyped(ColumnTyped <DataT> sourceColumn, ArrayRange sourceIndices)
 {
     using (Profiling.GetMarker(Profiling.MarkerId.MergeMax).Auto())
     {
         DataT result = math.MinValue();
         foreach (var v in sourceColumn.VisitRows(sourceIndices))
         {
             result = math.Max(result, v);
         }
         return(result);
     }
 }
Exemplo n.º 19
0
    static (float, double) RunSort(SortSettings settings, Action randomizeList, Action sorting)
    {
        float timeMs = 0;

        for (int i = 0; i < settings.TestCount; i++)
        {
            randomizeList();
            timeMs += Profiling.ExecutingProfile(sorting);
        }

        return(timeMs / settings.TestCount, 0);
    }
 public string Get(string scope, string application, string section, string key)
 {
     using (new ProfileContext("CachedConfigurationStore.Get"))
     {
         var cacheKey = KeyMaker.ConstructKey(scope, application, section, key);
         Profiling.Trace($"Key: {key}");
         var result = LocalConfigurationRepository.IsKeyPresent(cacheKey)
                         ? LocalConfigurationRepository.Get(cacheKey)
                         : GetFromRemote(scope, application, section, key);
         return(result);
     }
 }
Exemplo n.º 21
0
        public IActionResult Create(Profiling profiling, Account account)
        {
            applicationDbContext.Add(profiling);
            applicationDbContext.Add(account);
            var result = applicationDbContext.SaveChanges();

            if (result > 0)
            {
                return(RedirectToAction(nameof(Index)));
            }
            return(View());
        }
Exemplo n.º 22
0
 protected override IComparable GroupTyped(ColumnTyped <DataT> sourceColumn, ArrayRange sourceIndices)
 {
     using (Profiling.GetMarker(Profiling.MarkerId.MergeAverage).Auto())
     {
         DataT result = math.Zero();
         foreach (var v in sourceColumn.VisitRows(sourceIndices))
         {
             result = math.Add(result, v);
         }
         result = math.Div(result, math.Make(sourceIndices.indexCount));
         return(result);
     }
 }
Exemplo n.º 23
0
        private static void LoopEndPoint()
        {
            Profiling finish = ProfilingDictionary[typeof(PostLateUpdate.FinishFrameRendering)];

            float endTime = finish.EndTime;

            foreach (var kv in ProfilingDictionary)
            {
                PrevSubSystemExecuteTimeDictionary[kv.Key] = kv.Value.ExecuteTime;
                kv.Value.Reset();
            }
            _prevLoopExecuteTime = endTime - _loopStartTime;
        }
Exemplo n.º 24
0
        protected void Profile(String label, Action action)
        {
            label = FormatProfileLabel(label);

            DateTime start = DateTime.UtcNow;

            action();
            var duration = DateTime.UtcNow - start;

            Profiling.AddRecord(label, duration);
            ProfilingEntries.TryAdd(label, duration);

            logger.LogDebug("{0} took {1}ms", label, (int)duration.TotalMilliseconds);
        }
Exemplo n.º 25
0
        protected T Profile <T>(String label, Func <T> func)
        {
            label = FormatProfileLabel(label);

            DateTime start    = DateTime.UtcNow;
            T        result   = func();
            var      duration = DateTime.UtcNow - start;

            Profiling.AddRecord(label, duration);
            ProfilingEntries.TryAdd(label, duration);

            logger.LogDebug("{0} took {1}ms", label, (int)duration.TotalMilliseconds);
            return(result);
        }
Exemplo n.º 26
0
        public override int Read(byte[] buffer, int offset, int count)
        {
            try
            {
                Profiling.Stamp("SS Reader Wait");
                var b = _readerUnlock.WaitOne();
                if (!b)
                {
                    return(0);
                }
                Profiling.Stamp("SS Reader Unlocked");
                if (_readTo > _readFrom)
                {
                    var m = Math.Min(count, _readTo - _readFrom);
                    Array.Copy(_readBuf, _readFrom, buffer, offset, m);
                    _readFrom += m;
                    if (_readFrom < _readTo)
                    {
                        // var rem = _readTo - _readFrom;
                        // Array.Copy(_readBuf, _readFrom, _readBuf, 0, _readTo - _readFrom);
                        // _readFrom = 0;
                        // _readTo = rem;
                    }
                    else
                    {
                        _readFrom = 0;
                        _readTo   = 0;
                        _readerUnlock.Reset();
                        _readerFinished.Set();
                    }
                    return(m);
                }
                return(0);
            }
            catch
            {
                // reset
                _readFrom = 0;
                _readTo   = 0;
                _readerUnlock.Reset();
                _readerFinished.Set();

                Dispose();
                throw;
            }
            finally
            {
            }
        }
Exemplo n.º 27
0
        protected async Task Profile(String label, Func <Task> func)
        {
            label = FormatProfileLabel(label);

            DateTime start = DateTime.UtcNow;

            await func();

            var duration = DateTime.UtcNow - start;

            Profiling.AddRecord(label, duration);
            ProfilingEntries.TryAdd(label, duration);

            logger.LogDebug("{0} took {1}ms", label, (int)duration.TotalMilliseconds);
        }
Exemplo n.º 28
0
    static (float, double) RunSortWithMemoryDebug(SortSettings settings, Action randomizeList, Action sorting)
    {
        float  timeMs   = 0;
        double memoryKb = 0;

        for (int i = 0; i < settings.TestCount; i++)
        {
            randomizeList();
            memoryKb += Profiling.MemoryProfile(() =>
            {
                timeMs += Profiling.ExecutingProfile(sorting);
            });
        }

        return(timeMs / settings.TestCount, memoryKb / settings.TestCount);
    }
Exemplo n.º 29
0
 protected override IComparable GroupTyped(ColumnTyped <DataT> sourceColumn, ArrayRange sourceIndices)
 {
     using (Profiling.GetMarker(Profiling.MarkerId.MergeSumPositive).Auto())
     {
         DataT result = math.Zero();
         DataT z      = math.Zero();
         foreach (var v in sourceColumn.VisitRows(sourceIndices))
         {
             if (math.Compare(v, z) >= 0)
             {
                 result = math.Add(result, v);
             }
         }
         return(result);
     }
 }
Exemplo n.º 30
0
 public override BaseMode BuildViewSchemaClone(Database.View.ViewSchema.Builder builder)
 {
     Database.View.ViewSchema vs;
     using (Profiling.GetMarker(Profiling.MarkerId.BuildViewDefinitionFile).Auto())
     {
         vs = builder.Build(m_RawSchema);
     }
     if (vs != null)
     {
         SnapshotMode copy = new SnapshotMode(this);
         copy.ViewSchema      = vs;
         copy.SchemaToDisplay = vs;
         copy.UpdateTableSelectionNames();
         return(copy);
     }
     return(null);
 }
Exemplo n.º 31
0
 public void OnError(IDbCommand profiledDbCommand, Profiling.Data.SqlExecuteType executeType, Exception exception)
 {
     var formatter = new Profiling.SqlFormatters.SqlServerFormatter();
     exception.Data["SQL"] = formatter.FormatSql(profiledDbCommand.CommandText, SqlTiming.GetCommandParameters(profiledDbCommand));
     this.wrapped.OnError(profiledDbCommand, executeType, exception);
 }
Exemplo n.º 32
0
 public void ExecuteStart(IDbCommand profiledDbCommand, Profiling.Data.SqlExecuteType executeType)
 {
     this.wrapped.ExecuteStart(profiledDbCommand, executeType);
 }
Exemplo n.º 33
0
 public ErrorLoggingProfiler(Profiling.Data.IDbProfiler wrapped)
 {
     this.wrapped = wrapped;
 }
Exemplo n.º 34
0
 public void ExecuteFinish(IDbCommand profiledDbCommand, Profiling.Data.SqlExecuteType executeType, DbDataReader reader)
 {
     this.wrapped.ExecuteFinish(profiledDbCommand, executeType, reader);
 }
Exemplo n.º 35
0
 public Reports(Profiling.Report[] reports) {
     Report = reports;
 }