Ejemplo n.º 1
0
        public void TestUsage()
        {
            MemoryUsage usage1 = new MemoryUsage(2048);

            Assert.That(!usage1.IsFull());
            Assert.That(usage1.Usage == 0);

            usage1.IncreaseUsage(1024);

            Assert.That(!usage1.IsFull());
            Assert.That(usage1.Usage == 1024);

            usage1.DecreaseUsage(512);

            Assert.That(!usage1.IsFull());
            Assert.That(usage1.Usage == 512);

            usage1.Usage = 2048;

            Assert.That(usage1.IsFull());
            Assert.That(usage1.Usage == 2048);

            usage1.IncreaseUsage(1024);
            Assert.That(usage1.IsFull());
            Assert.That(usage1.Usage == 3072);
        }
Ejemplo n.º 2
0
        public MessageProducer(Session session, ProducerId id, ActiveMQDestination destination, TimeSpan requestTimeout)
        {
            this.session        = session;
            this.RequestTimeout = requestTimeout;

            this.info             = new ProducerInfo();
            this.info.ProducerId  = id;
            this.info.Destination = destination;
            this.info.WindowSize  = session.Connection.ProducerWindowSize;

            this.messageTransformation = session.Connection.MessageTransformation;

            // If the destination contained a URI query, then use it to set public
            // properties on the ProducerInfo
            if (destination != null && destination.Options != null)
            {
                URISupport.SetProperties(this.info, destination.Options, "producer.");
            }

            // Version Three and higher will send us a ProducerAck, but only if we
            // have a set producer window size.
            if (session.Connection.ProtocolVersion >= 3 && this.info.WindowSize > 0)
            {
                if (Tracer.IsDebugEnabled)
                {
                    Tracer.Debug("MessageProducer created with a Window Size of: " + this.info.WindowSize);
                }
                this.usage = new MemoryUsage(this.info.WindowSize);
            }
        }
Ejemplo n.º 3
0
        public void WaitForIndexesToBecomeNonStale()
        {
            MemoryUsage.Clear();
            while (true)
            {
                process.Refresh();
                MemoryUsage.Add(process.WorkingSet64);

                var statistics = store.DatabaseCommands.GetStatistics();

                if (statistics.StaleIndexes.Length == 0 && doneImporting)
                {
                    return;
                }

                foreach (var staleIndex in statistics.StaleIndexes)
                {
                    var indexStats    = statistics.Indexes.Single(x => x.Name == staleIndex);
                    var latencyInTime = (DateTime.UtcNow - indexStats.LastIndexedTimestamp).TotalMilliseconds;
                    LatencyTimes.Add(new KeyValuePair <string, double>(staleIndex, latencyInTime));

                    var latencyInDocuments = statistics.CountOfDocuments - indexStats.IndexingAttempts;
                    LatencyInDocuments.Add(new KeyValuePair <string, long>(staleIndex, latencyInDocuments));

                    logger.Debug("Stale index {0} - {1:#,#}/{2:#,#} - latency: {3:#,#}, {4:#,#}ms", indexStats.Id, indexStats.IndexingAttempts, statistics.CountOfDocuments,
                                 latencyInDocuments,
                                 latencyInTime);
                }

                Thread.Sleep(1000);
            }
        }
Ejemplo n.º 4
0
        public void AddData()
        {
            MemoryUsage.Clear();
            doneImporting = false;
            var session = store.OpenSession();
            var count   = 0;

            logger.Info("Testing RavenDB Log");

            var sp = ParseDisks(diskToAdd =>
            {
                session.Store(diskToAdd);
                count += 1;
                if (count < BatchSize)
                {
                    return;
                }

                session.SaveChanges();
                session = store.OpenSession();
                count   = 0;
            });

            session.SaveChanges();

            logger.Info(" ");
            logger.Info("Done in {0}", sp.Elapsed);
            doneImporting = true;
        }
Ejemplo n.º 5
0
        public virtual void TestSimpleByteArrays()
        {
            MemoryMXBean memoryMXBean = ManagementFactory.MemoryMXBean;

            object[][] all = new object[0][];
            try
            {
                while (true)
                {
                    // Check the current memory consumption and provide the estimate.
                    CauseGc();
                    MemoryUsage mu        = memoryMXBean.HeapMemoryUsage;
                    long        estimated = ShallowSizeOf(all);
                    if (estimated > 50 * RamUsageEstimator.ONE_MB)
                    {
                        break;
                    }

                    Console.WriteLine(string.format(Locale.ROOT, "%10s\t%10s\t%10s", RamUsageEstimator.humanReadableUnits(mu.Used), RamUsageEstimator.humanReadableUnits(mu.Max), RamUsageEstimator.humanReadableUnits(estimated)));

                    // Make another batch of objects.
                    object[] seg = new object[10000];
                    all = Arrays.copyOf(all, all.Length + 1);
                    all[all.Length - 1] = seg;
                    for (int i = 0; i < seg.Length; i++)
                    {
                        seg[i] = new sbyte[Random().Next(7)];
                    }
                }
            }
            catch (System.OutOfMemoryException e)
            {
                // Release and quit.
            }
        }
        public void Setup()
        {
            _statsd = new Mock <IVeStatsDClient>();
            _statsd.Setup(x => x.LogGauge(It.IsAny <string>(), It.IsAny <int>(), It.IsAny <Dictionary <string, string> >()));
            _metric = new MemoryUsage();

            _metric.Execute(_statsd.Object);
        }
 public void Unpublish()
 {
     CpuUsage.Unpublish();
     CpuCapacity.Unpublish();
     MemoryUsage.Unpublish();
     TotalNetworkBytesIn.Unpublish();
     TotalNetworkBytesOut.Unpublish();
     TotalDiskBytesRead.Unpublish();
     TotalDiskBytesWrite.Unpublish();
 }
 public void Dispose()
 {
     CpuUsage.Remove();
     CpuCapacity.Remove();
     MemoryUsage.Remove();
     TotalNetworkBytesIn.Remove();
     TotalNetworkBytesOut.Remove();
     TotalDiskBytesRead.Remove();
     TotalDiskBytesWrite.Remove();
 }
Ejemplo n.º 9
0
        private Stopwatch ParseDisks(Action <Disk> addToBatch)
        {
            int i      = 0;
            var parser = new Parser();
            var buffer = new byte[1024 * 1024];            // more than big enough for all files

            var sp = Stopwatch.StartNew();

            using (var bz2 = new BZip2InputStream(File.Open(dataLocation, FileMode.Open)))
                using (var tar = new TarInputStream(bz2))
                {
                    TarEntry entry;
                    while ((entry = tar.GetNextEntry()) != null)
                    {
                        if (entry.Size == 0 || entry.Name == "README" || entry.Name == "COPYING")
                        {
                            continue;
                        }
                        var readSoFar = 0;
                        while (true)
                        {
                            var read = tar.Read(buffer, readSoFar, ((int)entry.Size) - readSoFar);
                            if (read == 0)
                            {
                                break;
                            }

                            readSoFar += read;
                        }
                        // we do it in this fashion to have the stream reader detect the BOM / unicode / other stuff
                        // so we can read the values properly
                        var fileText = new StreamReader(new MemoryStream(buffer, 0, readSoFar)).ReadToEnd();
                        try
                        {
                            var disk = parser.Parse(fileText);
                            addToBatch(disk);
                            if (i++ % BatchSize == 0)
                            {
                                process.Refresh();
                                MemoryUsage.Add(process.WorkingSet64);
                                logger.Info("\r{0} {1:#,#} {2} ", entry.Name, i, sp.Elapsed);
                            }
                        }
                        catch (Exception e)
                        {
                            logger.Error("");
                            logger.Error(entry.Name);
                            logger.Error(e);
                            return(sp);
                        }
                    }
                }
            return(sp);
        }
Ejemplo n.º 10
0
        internal async Task DoSendAsync(ActiveMQDestination destination, ActiveMQMessage message,
                                        MessageProducer producer, MemoryUsage producerWindow, TimeSpan sendTimeout)
        {
            ActiveMQMessage msg = message;

            if (destination.IsTemporary && !connection.IsTempDestinationActive(destination as ActiveMQTempDestination))
            {
                throw new InvalidDestinationException("Cannot publish to a deleted Destination: " + destination);
            }

            if (IsTransacted)
            {
                DoStartTransaction();
                msg.TransactionId = TransactionContext.TransactionId;
            }

            msg.RedeliveryCounter = 0;
            msg.BrokerPath        = null;

            if (this.connection.CopyMessageOnSend)
            {
                msg = (ActiveMQMessage)msg.Clone();
            }

            msg.OnSend();
            msg.ProducerId = msg.MessageId.ProducerId;

            if (sendTimeout.TotalMilliseconds <= 0 && !msg.ResponseRequired && !connection.AlwaysSyncSend &&
                (!msg.Persistent || connection.AsyncSend || msg.TransactionId != null))
            {
                this.connection.Oneway(msg);

                if (producerWindow != null)
                {
                    // Since we defer lots of the marshaling till we hit the wire, this
                    // might not provide and accurate size. We may change over to doing
                    // more aggressive marshaling, to get more accurate sizes.. this is more
                    // important once users start using producer window flow control.
                    producerWindow.IncreaseUsage(msg.Size());
                }
            }
            else
            {
                if (sendTimeout.TotalMilliseconds > 0)
                {
                    await this.connection.SyncRequestAsync(msg, sendTimeout).Await();
                }
                else
                {
                    await this.connection.SyncRequestAsync(msg).Await();
                }
            }
        }
Ejemplo n.º 11
0
        public void TestConstructors()
        {
            MemoryUsage usage = new MemoryUsage();

            Assert.That(usage.Limit == 0);
            Assert.That(usage.Usage == 0);

            usage = new MemoryUsage(1024);

            Assert.That(usage.Limit == 1024);
            Assert.That(usage.Usage == 0);
        }
Ejemplo n.º 12
0
        public MessageProducer(Session session, ProducerInfo info)
        {
            this.session        = session;
            this.info           = info;
            this.RequestTimeout = session.RequestTimeout;

            // Version Three and higher will send us a ProducerAck, but only if we
            // have a set producer window size.
            if (session.Connection.ProtocolVersion >= 3 && info.WindowSize > 0)
            {
                usage = new MemoryUsage(info.WindowSize);
            }
        }
Ejemplo n.º 13
0
        private void DoMemoryUpdates()
        {
            MemoryMXBean memoryMXBean = ManagementFactory.GetMemoryMXBean();
            MemoryUsage  memNonHeap   = memoryMXBean.GetNonHeapMemoryUsage();
            MemoryUsage  memHeap      = memoryMXBean.GetHeapMemoryUsage();
            Runtime      runtime      = Runtime.GetRuntime();

            metrics.SetMetric("memNonHeapUsedM", memNonHeap.GetUsed() / M);
            metrics.SetMetric("memNonHeapCommittedM", memNonHeap.GetCommitted() / M);
            metrics.SetMetric("memHeapUsedM", memHeap.GetUsed() / M);
            metrics.SetMetric("memHeapCommittedM", memHeap.GetCommitted() / M);
            metrics.SetMetric("maxMemoryM", runtime.MaxMemory() / M);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Save resource usage to database
        /// </summary>
        public void SaveUsage()
        {
            CpuUsage    cpuUsage        = new CpuUsage();
            MemoryUsage memoryAvailable = new MemoryUsage();

            while (true)
            {
                float cpuUsageValue    = cpuUsage.Current();
                float memoryUsageValue = memoryAvailable.Current();
                Console.WriteLine(Convert.ToString(cpuUsageValue) + "% || " + Convert.ToString(memoryUsageValue) + " MB");
                this.dbHandler.SaveResourceUsage(new TotalResourceUsageModel(this.SecondsSinceEpoh(), cpuUsageValue, memoryUsageValue));
            }
        }
Ejemplo n.º 15
0
        private void GetMemoryUsage(MetricsRecordBuilder rb)
        {
            MemoryUsage memNonHeap = memoryMXBean.GetNonHeapMemoryUsage();
            MemoryUsage memHeap    = memoryMXBean.GetHeapMemoryUsage();
            Runtime     runtime    = Runtime.GetRuntime();

            rb.AddGauge(JvmMetricsInfo.MemNonHeapUsedM, memNonHeap.GetUsed() / M).AddGauge(JvmMetricsInfo
                                                                                           .MemNonHeapCommittedM, memNonHeap.GetCommitted() / M).AddGauge(JvmMetricsInfo.MemNonHeapMaxM
                                                                                                                                                          , memNonHeap.GetMax() / M).AddGauge(JvmMetricsInfo.MemHeapUsedM, memHeap.GetUsed
                                                                                                                                                                                                  () / M).AddGauge(JvmMetricsInfo.MemHeapCommittedM, memHeap.GetCommitted() / M).AddGauge
                (JvmMetricsInfo.MemHeapMaxM, memHeap.GetMax() / M).AddGauge(JvmMetricsInfo.MemMaxM
                                                                            , runtime.MaxMemory() / M);
        }
Ejemplo n.º 16
0
        public void TestTimedWait()
        {
            MemoryUsage usage = new MemoryUsage(2048);

            usage.IncreaseUsage(5072);

            DateTime start = DateTime.Now;

            usage.WaitForSpace(TimeSpan.FromMilliseconds(150));

            DateTime end = DateTime.Now;

            TimeSpan timePassed = end - start;

            Assert.That(timePassed.TotalMilliseconds >= 125);
        }
Ejemplo n.º 17
0
        public IDisposable MeasureEventMemoryUsage(string componentName, string eventName)
        {
            if (!StateSynchronizationPerformanceParameters.EnablePerformanceReporting)
            {
                return(null);
            }

            var key = new PerformanceEventKey(componentName, eventName);

            if (!eventMemoryUsage.TryGetValue(key, out var memoryUsage))
            {
                memoryUsage = new MemoryUsage();
                eventMemoryUsage.Add(key, memoryUsage);
            }

            return(new MemoryScope(memoryUsage));
        }
Ejemplo n.º 18
0
 public AllocationCreateInfo(AllocationCreateFlags flags      = default,
                             AllocationStrategyFlags strategy = default,
                             MemoryUsage usage = default,
                             MemoryPropertyFlags requiredFlags  = default,
                             MemoryPropertyFlags preferredFlags = default,
                             uint memoryTypeBits   = 0,
                             VulkanMemoryPool?pool = null,
                             object?userData       = null)
 {
     Flags          = flags;
     Strategy       = strategy;
     Usage          = usage;
     RequiredFlags  = requiredFlags;
     PreferredFlags = preferredFlags;
     MemoryTypeBits = memoryTypeBits;
     Pool           = pool;
     UserData       = userData;
 }
Ejemplo n.º 19
0
        public void TestWait()
        {
            MemoryUsage usage = new MemoryUsage(2048);

            usage.IncreaseUsage(5072);

            Thread thread1 = new Thread(delegate()
            {
                Thread.Sleep(100);
                usage.DecreaseUsage(usage.Usage);
            });

            thread1.Start();

            usage.WaitForSpace();
            Assert.That(usage.Usage == 0);

            thread1.Join();
        }
Ejemplo n.º 20
0
        void LookLikeTheOldStructure()
        {
            // We used to just put a Dictionary<string, string> in there, but for better OO principles I changed it to an
            // object. Unfortunately, I broke it when I did that so it stored an array of the objects and it didn't deserialize
            // properly any more. Let's make sure when a Data object with the new object is used that it matches the old format.

            string old_format            = "{\"Value\":{\"Memory Capacity\":\"17098178560\",\"Free Memory\":\"15014670336\",\"Memory Used\":\"2083508224\"}}";
            DataCollectorContext context = new DataCollectorContext(new CollectorID(-1, "Memory"), ECollectorType.Memory);
            MemoryUsage          usage   = new MemoryUsage()
            {
                CapacityNum = 17098178560, FreeNum = 15014670336
            };
            Data   d          = new GenericData <MemoryUsage>(context, usage);
            string new_format = JsonConvert.SerializeObject(d, Newtonsoft.Json.Formatting.None,
                                                            new Newtonsoft.Json.JsonSerializerSettings {
                StringEscapeHandling = StringEscapeHandling.EscapeHtml
            });

            Assert.Equal(old_format, new_format);
        }
Ejemplo n.º 21
0
            public MemoryScope(MemoryUsage memoryUsage)
            {
                calculationCompleted = false;

                if (!Profiler.enabled)
                {
                    UnityEngine.Debug.LogError($"Profiler not enabled, MemoryUsage not supported.");
                    this.memoryUsage        = null;
                    startingAllocatedMemory = 0;
                    startingReservedMemory  = 0;
                    startingUnusedMemory    = 0;
                }
                else
                {
                    this.memoryUsage        = memoryUsage;
                    startingAllocatedMemory = Profiler.GetTotalAllocatedMemoryLong();
                    startingReservedMemory  = Profiler.GetTotalReservedMemoryLong();
                    startingUnusedMemory    = Profiler.GetTotalUnusedReservedMemoryLong();
                }
            }
Ejemplo n.º 22
0
        /// <summary>
        /// Result from the free command
        /// </summary>
        public static MemoryUsage ServerMemoryUsage()
        {
            try
            {
                using (Process proc = new Process()
                {
                    StartInfo = new ProcessStartInfo {
                        FileName = "free",
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow = true
                    }
                })
                {
                    proc.Start();
                    proc.WaitForExit();
                    //Skip labels
                    proc.StandardOutput.ReadLine();
                    string      l       = proc.StandardOutput.ReadLine();
                    string      lc      = proc.StandardOutput.ReadLine();
                    string[]    values  = l.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    string[]    valuesc = lc.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                    MemoryUsage mu      = new MemoryUsage();
                    if (values.Length >= 3)
                    {
                        //Megs
                        mu.Total = double.Parse(values [1]) * 1024;
                        mu.Used  = double.Parse(valuesc [2]) * 1024;
#if DEBUG
                        //mu.Used = 0.99 * mu.Total;
#endif
                    }
                    return(mu);
                }
            } catch (Exception)
            {
                return(null);
            }
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Result from the free command
        /// </summary>
        public static MemoryUsage ServerMemoryUsage()
        {
            try
            {
                using (Process proc = new Process() {
                    StartInfo = new ProcessStartInfo {
                        FileName = "free",
                        UseShellExecute = false,
                        RedirectStandardOutput = true,
                        CreateNoWindow = true
                    }
                })
                {
                    proc.Start();
                    proc.WaitForExit();
                    //Skip labels
                    proc.StandardOutput.ReadLine();
                    string l = proc.StandardOutput.ReadLine();
                    string lc = proc.StandardOutput.ReadLine();
                    string[] values = l.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
                    string[] valuesc = lc.Split(new char[]{' '}, StringSplitOptions.RemoveEmptyEntries);
                    MemoryUsage mu = new MemoryUsage();
                    if (values.Length >= 3)
                    {
                        //Megs
                        mu.Total = double.Parse(values [1]) * 1024; 
                        mu.Used = double.Parse(valuesc [2]) * 1024; 
#if DEBUG
                        //mu.Used = 0.99 * mu.Total;
#endif
                    }
                    return mu;
                }
            } catch (Exception)
            {
                return null;
            }
        }
Ejemplo n.º 24
0
 /// <summary>
 /// Initialize the event data.
 /// </summary>
 /// <param name="currentMemoryUsage"></param>
 public void Initialize(MemoryUsage currentMemoryUsage)
 {
     BaseInitialize();
     CurrentMemoryUsage = currentMemoryUsage;
 }
Ejemplo n.º 25
0
        private void drawMemoryGraph()
        {
            Graphics g = Graphics.FromImage(memoryGraph);

            int fw = memoryGraph.Width;
            int fh = memoryGraph.Height;

            ulong  totalMemory = (ulong)memStats.TotalVisibleMemorySize * 1024;
            double rate;

            MemoryUsage latestUsage = memStats.Latest;

            if (latestUsage.Used + latestUsage.Available > totalMemory * 1.5)
            {
                rate = (double)fh / (totalMemory * 3.0);// (double)memStats.CommitLimit;
            }
            else
            {
                rate = (double)fh / (totalMemory * 1.5);
            }

            int border = (int)(totalMemory * rate);

            g.FillRectangle(new SolidBrush(Color.White), 0, 0, fw, fh);
            Pen pen = new Pen(Color.FromArgb(220, 220, 220), 1F);

            for (int y = fh; y > 0; y -= (int)(256 * 1024 * 1024 * rate))
            {
                g.DrawLine(pen, 0, y, fw, y);
            }

            g.SmoothingMode = SmoothingMode.None;
            Brush availableBrush   = new SolidBrush(Color.FromArgb(180, 100, 100, 255));
            Brush kernelBrush      = new SolidBrush(Color.FromArgb(180, 255, 0, 0));
            Brush commitedBrush    = new SolidBrush(Color.FromArgb(180, 255, 145, 0));
            Brush systemCacheBrush = new SolidBrush(Color.FromArgb(50, 255, 0, 0));
            //			Brush spaceBrush = new SolidBrush(Color.FromArgb(180, 240, 230, 255));
            Brush spaceBrush = new SolidBrush(Color.FromArgb(100, 100, 100, 255));

            int count = memStats.Count;
            int bw    = (fw + (60 - 1)) / 60;

            for (int i = 0; i < count; i++)
            {
                MemoryUsage usage = memStats[i];

                int x = fw - i * bw - bw;
                int y = fh;
                int w = bw;
                int h = 0;

                h  = (int)((usage.KernelTotal) * rate);
                y -= h;
                g.FillRectangle(kernelBrush, x, y, w, h);

                h  = (int)(usage.SystemCache * rate);
                y -= h;
                g.FillRectangle(systemCacheBrush, x, y, w, h);

                h  = (int)((usage.Committed - usage.KernelTotal) * rate);
                y -= h;
                g.FillRectangle(commitedBrush, x, y, w, h);

                h  = (int)(usage.Available * rate);
                y -= h;
                g.FillRectangle(availableBrush, x, y, w, h);

                h = y;
                y = 0;
                g.FillRectangle(spaceBrush, x, y, w, h);


                x = fw - i * bw - bw;
                w = bw / 2;
                h = (int)(usage.Pagein);
                y = fh - h;
                g.FillRectangle(Brushes.LightGray, x, y, w, h);

                x = fw + bw / 2 - i * bw - bw;
                w = bw / 2;
                h = (int)(usage.Pageout);
                y = fh - h;
                g.FillRectangle(Brushes.Black, x, y, w, h);
            }
            Pen borderPen = new Pen(Color.Blue);

            borderPen.DashStyle = DashStyle.Dash;
            g.DrawLine(borderPen, 0, fh - border, fw, fh - border);

            g.Dispose();

            if (memStats.Count > 0)
            {
                MemoryUsage u = memStats[0];
                lblTotal.Text    = (memStats.TotalVisibleMemorySize / (1024.0)).ToString("#####0.0MB");
                lblFree.Text     = (u.Available / (1048576.0)).ToString("#####0.0MB");
                lblCommited.Text = (u.Committed / (1048576.0)).ToString("#####0.0MB");
                lblSysCache.Text = (u.SystemCache / (1048576.0)).ToString("#####0.0MB");
                lblSystem.Text   = (u.KernelTotal / (1048576.0)).ToString("#####0.0MB");
            }
        }
Ejemplo n.º 26
0
        public void CountProcessorUsage(object sender, EventArgs e)
        {
            cpuStats.Update();
            CPUUsage cpuUsage = cpuStats.Latest;

            memStats.Update();
            MemoryUsage memUsage = memStats.Latest;

            pageio_count += memUsage.Pageout * (memUsage.Pagein + 1);
            //if (pageio_count > 0) pageio_count += memUsage.Pagein;
            pageio_count -= pageio_count / 50 + 1;
            if (pageio_count < 0)
            {
                pageio_count = 0;
            }

            int pattern = cpuUsage.Active / 10;

            pattern += memUsage.Pageout / 15;
            pattern += memUsage.Pagein / 30;
            if (pattern > 10)
            {
                pattern = 10;
            }

            FaceDef.PatternSuite suite = FaceDef.PatternSuite.Normal;

            UInt64 avilable = (UInt64)memStats.TotalVisibleMemorySize * 1024 - memUsage.Used;

            if (pageio_count > 100)
            {
                suite = FaceDef.PatternSuite.MemoryInsufficient;
            }
            else if (avilable < 0)
            {
                suite = FaceDef.PatternSuite.MemoryDecline;
            }

            int markers = FaceDef.MarkerNone;

            if (memUsage.Pagein > 0)
            {
                markers += FaceDef.MarkerPageIn;
            }
            if (memUsage.Pageout > 0)
            {
                markers += FaceDef.MarkerPageOut;
            }

            if (patternWindow != null)
            {
                patternWindow.UpdatePattern(suite, pattern, markers);
            }

            if (statusWindow != null)
            {
                statusWindow.UpdateGraph();
            }

            if (optimusMini.IsAlive && curFaceDef != null)
            {
                Bitmap   image = new Bitmap(96, 96);
                Graphics g     = Graphics.FromImage(image);
                g.FillRectangle(new SolidBrush(Color.White), 0, 0, image.Width, image.Height);
                curFaceDef.DrawPatternImage(g, suite, pattern, markers, 96F / 128F);
                g.Dispose();

                optimusMini.ShowPicture(1, image);
            }
        }
Ejemplo n.º 27
0
 public MemoryNotificationInfo(String arg0, MemoryUsage arg1, long arg2)
     : base(ProxyCtor.I)
 {
     Instance.CallConstructor("(Ljava/lang/String;Ljava/lang/management/MemoryUsage;J)V", arg0, arg1, arg2);
 }
Ejemplo n.º 28
0
 public MemoryUsageTest()
 {
     _memoryUsage = new MemoryUsage(_timerFactory);
 }
        public override int GetHashCode()
        {
            int hash = 1;

            if (Name.Length != 0)
            {
                hash ^= Name.GetHashCode();
            }
            if (Id.Length != 0)
            {
                hash ^= Id.GetHashCode();
            }
            if (AppEngineRelease.Length != 0)
            {
                hash ^= AppEngineRelease.GetHashCode();
            }
            if (Availability != global::Google.Cloud.AppEngine.V1.Instance.Types.Availability.Unspecified)
            {
                hash ^= Availability.GetHashCode();
            }
            if (VmName.Length != 0)
            {
                hash ^= VmName.GetHashCode();
            }
            if (VmZoneName.Length != 0)
            {
                hash ^= VmZoneName.GetHashCode();
            }
            if (VmId.Length != 0)
            {
                hash ^= VmId.GetHashCode();
            }
            if (startTime_ != null)
            {
                hash ^= StartTime.GetHashCode();
            }
            if (Requests != 0)
            {
                hash ^= Requests.GetHashCode();
            }
            if (Errors != 0)
            {
                hash ^= Errors.GetHashCode();
            }
            if (Qps != 0F)
            {
                hash ^= pbc::ProtobufEqualityComparers.BitwiseSingleEqualityComparer.GetHashCode(Qps);
            }
            if (AverageLatency != 0)
            {
                hash ^= AverageLatency.GetHashCode();
            }
            if (MemoryUsage != 0L)
            {
                hash ^= MemoryUsage.GetHashCode();
            }
            if (VmStatus.Length != 0)
            {
                hash ^= VmStatus.GetHashCode();
            }
            if (VmDebugEnabled != false)
            {
                hash ^= VmDebugEnabled.GetHashCode();
            }
            if (VmIp.Length != 0)
            {
                hash ^= VmIp.GetHashCode();
            }
            if (_unknownFields != null)
            {
                hash ^= _unknownFields.GetHashCode();
            }
            return(hash);
        }
Ejemplo n.º 30
0
        public static void ReadMessage(BinaryReader reader, out ParsedMessage message)
        {
            bool performanceMonitoringEnabled                   = reader.ReadBoolean();
            List <Tuple <string, double> >      durations       = null;
            List <Tuple <string, double> >      summedDurations = null;
            List <Tuple <string, int> >         counts          = null;
            List <Tuple <string, MemoryUsage> > memoryUsages    = null;

            if (!performanceMonitoringEnabled)
            {
                message = ParsedMessage.Empty;
                return;
            }

            int durationsCount = reader.ReadInt32();

            if (durationsCount > 0)
            {
                durations = new List <Tuple <string, double> >();
                for (int i = 0; i < durationsCount; i++)
                {
                    string eventName     = reader.ReadString();
                    double eventDuration = reader.ReadDouble();
                    durations.Add(new Tuple <string, double>(eventName, eventDuration));
                }
            }

            int summedDurationsCount = reader.ReadInt32();

            if (summedDurationsCount > 0)
            {
                summedDurations = new List <Tuple <string, double> >();
                for (int i = 0; i < summedDurationsCount; i++)
                {
                    string eventName     = reader.ReadString();
                    double eventDuration = reader.ReadDouble();
                    summedDurations.Add(new Tuple <string, double>(eventName, eventDuration));
                }
            }

            int countsCount = reader.ReadInt32();

            if (countsCount > 0)
            {
                counts = new List <Tuple <string, int> >();
                for (int i = 0; i < countsCount; i++)
                {
                    string eventName  = reader.ReadString();
                    int    eventCount = reader.ReadInt32();
                    counts.Add(new Tuple <string, int>(eventName, eventCount));
                }
            }

            int memoryUsageCount = reader.ReadInt32();

            if (memoryUsageCount > 0)
            {
                memoryUsages = new List <Tuple <string, MemoryUsage> >();
                for (int i = 0; i < memoryUsageCount; i++)
                {
                    string      eventName = reader.ReadString();
                    MemoryUsage usage     = new MemoryUsage();
                    usage.TotalAllocatedMemory      = reader.ReadInt64();
                    usage.TotalReservedMemory       = reader.ReadInt64();
                    usage.TotalUnusedReservedMemory = reader.ReadInt64();
                    memoryUsages.Add(new Tuple <string, MemoryUsage>(eventName, usage));
                }
            }

            message = new ParsedMessage(performanceMonitoringEnabled, durations, summedDurations, counts, memoryUsages);
        }