Esempio n. 1
0
        public void Parse()
        {
            var parser = new MetricParser();

            Assert.AreEqual(
                new Metric("gaugor", "+0", MetricType.Gauge, 1),
                parser.ParseMetric("gaugor:+0|g"));

            Assert.AreEqual(
                new Metric("gaugor", "-10", MetricType.Gauge, 1),
                parser.ParseMetric("gaugor:-10|g"));

            Assert.AreEqual(
                new Metric("gaugor", "+10", MetricType.Gauge, 1),
                parser.ParseMetric("gaugor:+10|g"));

            Assert.AreEqual(
                new Metric("glork", "320", MetricType.Timer, 5),
                parser.ParseMetric("glork:320|ms|@5"));

            Assert.AreEqual(
                new Metric("glork", "frob", MetricType.Set, 5),
                parser.ParseMetric("glork:frob|s|@5"));

            Assert.AreEqual(
                new Metric("online", "*****@*****.**", MetricType.Set, 5),
                parser.ParseMetric("online:[email protected]|s|@5"));
        }
        public void ShouldExtractWarningFromWarningResultBlock()
        {
            var parser = new MetricParser();
            var block = @"<h2><a name=""Avoid namespaces with few types"" />The Query ""Avoid namespaces with few types"" has the following problems: </h2><h3>Warning: More than 0 results were returned</h3><table border=""1""><tr><thead><td><b>NamespaceId</b></td><td><b>FullName</b></td><td><b>Count</b></td></thead></tr>";
            var metric = parser.Parse(block);

            Assert.IsTrue(metric.Warning);
        }
        public void ShouldExtractMetricFromZeroResultBlock()
        {
            var parser = new MetricParser();
            var block = @"<h2><a name=""Henderson Sellers Lack of Cohesion"" />The Query ""Henderson Sellers Lack of Cohesion"" returned the following results: </h2>No Results to display<br /><br />";
            var metric = parser.Parse(block);

            Assert.AreEqual("Henderson Sellers Lack of Cohesion", metric.Name);
            Assert.AreEqual(0, metric.Value);
        }
        public void ShouldExtractMetricFromMultipleResultBlock()
        {
            var parser = new MetricParser();
            var block = @"<h2><a name=""Methods that take or return System.Object"" />The Query ""Methods that take or return System.Object"" returned the following results: </h2><table border=""1""><tr><thead><td><b>MethodId</b></td><td><b>Name</b></td><td><b>FullName</b></td><td><b>TakeObjectParam</b></td><td><b>ReturnsObject</b></td></thead></tr><tr><td class=""numeric"">45</td><td><Load>b__0</td><td>Makemedia.ServerManager.Mappings.AutoMapperModule.<Load>b__0</td><td>False</td><td>True</td></tr><tr><td class=""numeric"">63</td><td>Equals</td><td>.<>f__AnonymousType0`4.Equals</td><td>True</td><td>False</td></tr><tr><td class=""numeric"">64</td><td>Equals</td><td>.<>f__AnonymousType2`4.Equals</td><td>True</td><td>False</td></tr><tr><td class=""numeric"">65</td><td>Equals</td><td>.<>f__AnonymousType5`1.Equals</td><td>True</td><td>False</td></tr><tr><td class=""numeric"">66</td><td>Equals</td><td>.<>f__AnonymousType1`2.Equals</td><td>True</td><td>False</td></tr><tr><td class=""numeric"">67</td><td>Equals</td><td>.<>f__AnonymousType3`3.Equals</td><td>True</td><td>False</td></tr><tr><td class=""numeric"">69</td><td>Equals</td><td>.<>f__AnonymousType6`1.Equals</td><td>True</td><td>False</td></tr><tr><td class=""numeric"">70</td><td>Equals</td><td>.<>f__AnonymousType4`1.Equals</td><td>True</td><td>False</td></tr><tr><td class=""numeric"">205</td><td>System.Collections.IEnumerator.get_Current</td><td>Makemedia.ServerManager.Services.<GetSites>d__0.System.Collections.IEnumerator.get_Current</td><td>False</td><td>True</td></tr></table><br /><br />";
            var metric = parser.Parse(block);

            Assert.AreEqual("Methods that take or return System.Object", metric.Name);
            Assert.AreEqual(9, metric.Value);
        }
Esempio n. 5
0
        public void ParsePerf()
        {
            var names   = Enumerable.Range(0, 10000).Select(n => RandomString(n % 59)).ToArray();
            var metrics = names.SelectMany(n => new[] { n + ":+0|g", n + ":-10|g", n + ":+10|g", n + ":320|ms|@5", n + ":frob|s|@5" }).ToArray();

            var parser = new MetricParser();

            parser.ParseMetric("gaugor:+0|g");

            var stopwatch = Stopwatch.StartNew();

            const int N = 100;

            for (var i = 0; i < N; ++i)
            {
                foreach (var metric in metrics)
                {
                    parser.ParseMetric(metric);
                }
            }

            Console.WriteLine("{0} in {1}", N * metrics.Length, stopwatch.Elapsed);
        }
 public void ShouldThrowWhenNameNotPresent()
 {
     var parser = new MetricParser();
     var block = @"<h2><a alpha=""Henderson Sellers Lack of Cohesion"" /></h2>";
     Assert.Throws<InvalidOperationException>(() => parser.Parse(block));
 }