Пример #1
0
            public void Finish(long iterations)
            {
                endCycleCount = unchecked ((long)Processor.CycleCount);

#if X64_PERF
                x64_p0 = Processor.ReadPmc(0);
                x64_p1 = Processor.ReadPmc(1);
                x64_p2 = Processor.ReadPmc(2);
                x64_p3 = Processor.ReadPmc(3);
#endif

                endInterruptCount = ProcessService.GetKernelInterruptCount();
                endSwitchCount    = ProcessService.GetContextSwitchCount();
                endKernelGcCount  = ProcessService.GetKernelGcCount();

                int  collectorCount;
                long collectorMillis;
                long collectorBytes;
                GC.PerformanceCounters(out collectorCount,
                                       out collectorMillis,
                                       out collectorBytes);
                endProcessGcCount = collectorCount;

                ulong allocatedCount;
                ulong allocatedBytes;
                ulong freedCount;
                ulong freedBytes;
                PageTableService.GetUsageStatistics(out allocatedCount,
                                                    out allocatedBytes,
                                                    out freedCount,
                                                    out freedBytes);
                endAllocatedCount = allocatedCount;
                endAllocatedBytes = allocatedBytes;
                endFreedCount     = freedCount;
                endFreedBytes     = freedBytes;

                ulong stackGets;
                ulong stackRets;
                StackService.GetUsageStatistics(out stackGets,
                                                out stackRets);
                endStackGets = stackGets;
                endStackRets = stackRets;

                if (!AtRing3)
                {
                    Processor.RestoreLocalPreemption(disabled);
                }

                this.iterations = iterations;
            }
Пример #2
0
            public void Start()
            {
                if (!AtRing3)
                {
                    disabled = Processor.DisableLocalPreemption();
                }

                int  collectorCount;
                long collectorMillis;
                long collectorBytes;

                GC.PerformanceCounters(out collectorCount,
                                       out collectorMillis,
                                       out collectorBytes);

                ulong stackGets;
                ulong stackRets;

                StackService.GetUsageStatistics(out stackGets,
                                                out stackRets);
                begStackGets = stackGets;
                begStackRets = stackRets;

                ulong allocatedCount;
                ulong allocatedBytes;
                ulong freedCount;
                ulong freedBytes;

                PageTableService.GetUsageStatistics(out allocatedCount,
                                                    out allocatedBytes,
                                                    out freedCount,
                                                    out freedBytes);
                begAllocatedCount = allocatedCount;
                begAllocatedBytes = allocatedBytes;
                begFreedCount     = freedCount;
                begFreedBytes     = freedBytes;

                begInterruptCount = ProcessService.GetKernelInterruptCount();
                begSwitchCount    = ProcessService.GetContextSwitchCount();
                begKernelGcCount  = ProcessService.GetKernelGcCount();
                begProcessGcCount = collectorCount;

#if x64_PERF
                // Set up for perf counting
                if (!AtRing3)
                {
                    // Reset the performance counters to what we're interested in.
                    Reset(0, PerfEvtSel.COUNT | PerfEvtSel.CyclesNotHalted);
                    Reset(1, PerfEvtSel.COUNT | PerfEvtSel.RetiredInstructions);
                    Reset(2, PerfEvtSel.COUNT | PerfEvtSel.RetiredBranchInstructions);
                    Reset(3, PerfEvtSel.COUNT | PerfEvtSel.RequestsToL2Cache | 0x400);
                }
                else
                {
                    // We're not allowed to reset the perf counters, so take note
                    // of their current values; we will subtract from this later.
                    x64_i0 = Processor.ReadPmc(0);
                    x64_i1 = Processor.ReadPmc(1);
                    x64_i2 = Processor.ReadPmc(2);
                    x64_i3 = Processor.ReadPmc(3);
                }
#endif

                begCycleCount = unchecked ((long)Processor.CycleCount);
            }