Ejemplo n.º 1
0
        private IEnumerable <ThreadProfilingModel> SerializeData()
        {
            var samples = new Dictionary <string, object>();

            if (_threadProfilingBucket.Tree.Root.Children.Count > 0)
            {
                samples.Add("OTHER", _threadProfilingBucket.Tree.Root.Children);
            }

            // Note: runnable thread count will always equal total thread count since we don't track the difference.
            var threadCount = _managedThreadsFromProfiler.Count;
            var model       = new ThreadProfilingModel(_profileSessionId, _startSessionTime, _stopSessionTime, _numberSamplesInSession, samples, threadCount, threadCount);

            // We only ever have one set of data, but collector expects an array of data
            return(new[] { model });
        }
Ejemplo n.º 2
0
        public void serializes_correctly()
        {
            var threadProfilingModel = new ThreadProfilingModel
                                       (
                1,
                new DateTime(2),
                new DateTime(3),
                4,
                new Dictionary <string, object> {
                { "OTHER", new ProfileNode(new UIntPtr(5), 6, 7) }
            },
                10,
                11
                                       );

            var json = JsonConvert.SerializeObject(threadProfilingModel);

            const string expectedJson = @"[1,-62135596800.0,-62135596800.0,4,{""OTHER"":[[null,null,0],6,0,[]]},10,11]";

            Assert.AreEqual(expectedJson, json);
        }