public static void GetMostExpensiveCalls(TextWriter wrt, MethodCallRecord R, int cnt = 0)
        {
            int i             = 1;
            var mostExpensive = R.CompleteCollectiveReport().OrderByDescending(cr => cr.ExclusiveTicks);

            foreach (var cr in mostExpensive)
            {
                wrt.Write("Rank " + i + ": ");
                wrt.WriteLine(cr.ToString());
                if (i == cnt)
                {
                    return;
                }
                i++;
            }
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="wrt"></param>
        /// <param name="R"></param>
        /// <param name="printcnt"></param>
        private static void GetMostExpensiveBlocking(TextWriter wrt, MethodCallRecord R, int printcnt = 0)
        {
            int i             = 1;
            var mostExpensive = R.CompleteCollectiveReport().OrderByDescending(cr => cr.TicksSpentInBlocking);

            foreach (var kv in mostExpensive)
            {
                wrt.Write("#" + i + ": ");
                wrt.WriteLine(string.Format(
                                  "'{0}': {1} calls, {2:0.##E-00} sec. runtime exclusivesec",
                                  kv.Name,
                                  kv.CallCount,
                                  new TimeSpan(kv.TicksSpentInBlocking).TotalSeconds));
                if (i == printcnt)
                {
                    return;
                }
                i++;
            }
            Console.Out.Flush();
        }
Beispiel #3
0
        private static void TestMethodCall(MethodCallRecord expected, string methodName, string className)
        {
            var target = new MethodCallTarget
            {
                Name = "t1",
                ClassName = className,
                MethodName = methodName
            };
            target.Parameters.Add(new MethodCallParameter("param1", "test1"));
            target.Parameters.Add(new MethodCallParameter("param2", "2", typeof(int)));

            var configuration = new LoggingConfiguration();
            configuration.AddTarget(target);
            configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, target));
            LogManager.Configuration = configuration;

            LastCallTest = null;

            LogManager.GetCurrentClassLogger().Debug("test method 1");

            Assert.Equal(expected, LastCallTest);
        }
Beispiel #4
0
 public static void StaticAndPublic(string param1, int param2)
 {
     LastCallTest = new MethodCallRecord("StaticAndPublic", param1, param2);
 }
Beispiel #5
0
 protected bool Equals(MethodCallRecord other)
 {
     return string.Equals(Method, other.Method) && ParameterValues.SequenceEqual(other.ParameterValues);
 }
Beispiel #6
0
        private static void TestMethodCall(MethodCallRecord expected, string methodName, string className)
        {
            var target = new MethodCallTarget
            {
                Name = "t1",
                ClassName = className,
                MethodName = methodName
            };
            target.Parameters.Add(new MethodCallParameter("param1", "test1"));
            target.Parameters.Add(new MethodCallParameter("param2", "2", typeof(int)));

            var configuration = new LoggingConfiguration();
            configuration.AddTarget(target);
            configuration.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, target));
            LogManager.Configuration = configuration;

            LastCallTest = null;

            LogManager.GetCurrentClassLogger().Debug("test method 1");

            Assert.Equal(expected, LastCallTest);
        }
Beispiel #7
0
 public static void StaticAndPrivate()
 {
     LastCallTest = new MethodCallRecord("StaticAndPrivate");
 }
 public static void PrintMostExpensiveBlocking(this MethodCallRecord mcr, int count)
 {
     GetMostExpensiveBlocking(Console.Out, mcr, count);
     Console.Out.Flush();
 }
Beispiel #9
0
 public void NonStaticAndPublic()
 {
     LastCallTest = new MethodCallRecord("NonStaticAndPublic");
 }
Beispiel #10
0
 public static void StaticAndPublicTooManyParameters(string param1, int param2, string param3)
 {
     LastCallTest = new MethodCallRecord("StaticAndPublicTooManyParameters", param1, param2);
 }
Beispiel #11
0
 public static void StaticAndPublicTooLessParameters(string param1)
 {
     LastCallTest = new MethodCallRecord("StaticAndPublicTooLessParameters", param1);
 }
Beispiel #12
0
 public static void StaticAndPublicWrongParameters(string param1, string param2)
 {
     LastCallTest = new MethodCallRecord("StaticAndPublic", param1, param2);
 }
Beispiel #13
0
 public static void StaticAndPublic(string param1, int param2)
 {
     LastCallTest = new MethodCallRecord("StaticAndPublic", param1, param2);
 }
Beispiel #14
0
 protected bool Equals(MethodCallRecord other)
 {
     return string.Equals(Method, other.Method) && ParameterValues.SequenceEqual(other.ParameterValues);
 }
Beispiel #15
0
        /// <summary>
        /// performs an integration over cells or edges in the composite rule provided to the constructor;
        /// </summary>
        public virtual void Execute()
        {
            using (var tr = new FuncTrace()) {
                // Init
                // ====

                // timers
                Stopwatch stpwSaveIntRes = new Stopwatch();
                stpwSaveIntRes.Reset();
                Stopwatch stpwQuad = new Stopwatch();
                stpwQuad.Reset();
                Stopwatch stpwEval = new Stopwatch();
                stpwEval.Reset();
                Stopwatch stpwAlloc = new Stopwatch();
                stpwAlloc.Reset();
                Stopwatch stpwNdSet = new Stopwatch();
                stpwNdSet.Reset();

                for (int i = CustomTimers.Length - 1; i >= 0; i--)
                {
                    CustomTimers[i].Reset();
                }

                // check input ...
                IGridData grd = gridData;

                // do quadrature
                // =============
                MultidimensionalArray lastQuadRuleNodes = null;
                int oldBulksize  = -1;
                int oldNoOfNodes = -1;
                int Bulkcnt      = 0;
                foreach (var chunkRulePair in m_compositeRule)
                {
                    Chunk chunk = chunkRulePair.Chunk;
                    m_CurrentRule = chunkRulePair.Rule;

                    //// init node set
                    stpwNdSet.Start();
                    if (!object.ReferenceEquals(m_CurrentRule.Nodes, lastQuadRuleNodes))
                    {
                        QuadNodesChanged(m_CurrentRule.Nodes);
                    }
                    stpwNdSet.Stop();

                    // define bulk size
                    int NoOfNodes = m_CurrentRule.Nodes.GetLength(0);
                    int ItemSize  = m_TotalNoOfIntegralsPerItem * NoOfNodes;
                    if (ItemSize <= 0)
                    {
                        continue;
                    }
                    int cdl = Quadrature_Bulksize.CHUNK_DATA_LIMIT;
                    if (ChunkDataLimitOverride > 0)
                    {
                        cdl = ChunkDataLimitOverride;
                    }
                    int MaxChunkLength = Quadrature_Bulksize.CHUNK_DATA_LIMIT / ItemSize;
                    if (MaxChunkLength < 1)
                    {
                        MaxChunkLength = 1;
                    }

                    //if (OberOasch && Bulkcnt == 0)
                    //    Console.WriteLine("Max Chunk length: " + MaxChunkLength);

                    int j           = chunk.i0;
                    int ChunkLength = MaxChunkLength;
                    int ChunkEnd    = chunk.i0 + chunk.Len;


                    while (j < ChunkEnd)
                    {
                        Bulkcnt++;

                        // limit bulksize
                        if ((j + ChunkLength) > ChunkEnd)
                        {
                            ChunkLength -= (j + ChunkLength - ChunkEnd);
                        }


                        // DEBUG check
#if DEBUG
                        CheckQuadratureChunk(j, ChunkLength, CurrentRuleRefElementIndex);
#endif

                        // reallocate buffers if bulksize was changed
                        stpwAlloc.Start();
                        if (ChunkLength != oldBulksize || m_CurrentRule.NoOfNodes != oldNoOfNodes)
                        {
                            AllocateBuffersInternal(ChunkLength, m_CurrentRule.Nodes);
                            AllocateBuffers(ChunkLength, m_CurrentRule.Nodes);
                            oldBulksize  = ChunkLength;
                            oldNoOfNodes = m_CurrentRule.NoOfNodes;
                        }
                        stpwAlloc.Stop();


                        if (this.m_ExEvaluate == null)
                        {
                            // evaluation of integrand
                            // =======================
                            stpwEval.Start();
                            m_EvalResults.Clear();
                            this.Evaluate(j, ChunkLength, this.CurrentRule, m_EvalResults);
                            stpwEval.Stop();

                            // quadrature
                            // ==========
                            stpwQuad.Start();
                            DoQuadrature(m_CurrentRule, j, ChunkLength);
                            stpwQuad.Stop();
                        }
                        else
                        {
                            Debug.Assert(this.m_Evaluate == null);

                            // evaluation of integrand
                            // =======================
                            stpwEval.Start();
                            this.m_ExEvaluate(j, ChunkLength, this.CurrentRule, m_QuadResults);
                            stpwEval.Stop();
                        }

                        // save results
                        // ============
                        stpwSaveIntRes.Start();
                        SaveIntegrationResults(j, ChunkLength, m_QuadResults);
                        stpwSaveIntRes.Stop();

                        // inc
                        j += ChunkLength;
                    }


                    lastQuadRuleNodes = m_CurrentRule.Nodes;
                }
                m_CurrentRule = null;

                //tr.Info("Quadrature performed in " + Bulkcnt + " chunk(s).");
                //Console.WriteLine("Quadrature performed in " + Bulkcnt + " chunk(s).");

                // finalize
                // ========

                {
                    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    //
                    // note that StopWatch.Elapsed.Ticks != StopWatch.ElapsedTicks
                    //
                    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
                    // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                    var mcrEval = tr.LogDummyblock(stpwEval.Elapsed.Ticks, "integrand_evaluation");
                    tr.LogDummyblock(stpwQuad.Elapsed.Ticks, "quadrature");
                    tr.LogDummyblock(stpwSaveIntRes.Elapsed.Ticks, "saving_results");
                    tr.LogDummyblock(stpwNdSet.Elapsed.Ticks, "node_set_management");
                    tr.LogDummyblock(stpwAlloc.Elapsed.Ticks, "buffer_allocation");

                    Debug.Assert(m_CustomTimers.Length == m_CustomTimers_Names.Length);
                    Debug.Assert(m_CustomTimers.Length == m_CustomTimers_RootPointer.Length);
                    MethodCallRecord[] mcrS = new MethodCallRecord[CustomTimers.Length];

                    for (int iTimer = 0; iTimer < mcrS.Length; iTimer++)
                    {
                        int pt = m_CustomTimers_RootPointer[iTimer];
                        MethodCallRecord OwnerMcr = pt >= 0 ? mcrS[pt] : mcrEval;
                        mcrS[iTimer] = OwnerMcr.AddSubCall(CustomTimers_Names[iTimer], m_CustomTimers[iTimer].Elapsed.Ticks);
                    }
                }
            }
        }
Beispiel #16
0
 public static void StaticAndPublicWrongParameters(string param1, string param2)
 {
     LastCallTest = new MethodCallRecord("StaticAndPublic", param1, param2);
 }
Beispiel #17
0
 public static void StaticAndPublicTooLessParameters(string param1)
 {
     LastCallTest = new MethodCallRecord("StaticAndPublicTooLessParameters", param1);
 }
Beispiel #18
0
 public static void StaticAndPublicTooManyParameters(string param1, int param2, string param3)
 {
     LastCallTest = new MethodCallRecord("StaticAndPublicTooManyParameters", param1, param2);
 }
Beispiel #19
0
 public static void StaticAndPublicOptional(string param1, int param2, string param3 = "fixedValue")
 {
     LastCallTest = new MethodCallRecord("StaticAndPublicOptional", param1, param2, param3);
 }
Beispiel #20
0
 public static void StaticAndPublicOptional(string param1, int param2, string param3 = "fixedValue")
 {
     LastCallTest = new MethodCallRecord("StaticAndPublicOptional", param1, param2, param3);
 }
Beispiel #21
0
 public static void StaticAndPrivate()
 {
     LastCallTest = new MethodCallRecord("StaticAndPrivate");
 }
Beispiel #22
0
 public void NonStaticAndPublic()
 {
     LastCallTest = new MethodCallRecord("NonStaticAndPublic");
 }