Beispiel #1
0
        static void Main(string[] args)
        {
            var connectionString = args.Length > 0 ? args[0] : System.Environment.GetEnvironmentVariable("REACTIVE_MACHINE_TELEMETRY");
            var containerName    = args.Length > 1 ? args[1] : "reactive-machine-results";
            var folderName       = args.Length > 2 ? args[2] : "folderName";

            if (args.Length > 2)
            {
                TaskGroup.ReadFromFile(connectionString, containerName, folderName, null);
            }

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Stats(connectionString, containerName, folderName));
        }
Beispiel #2
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            string container = comboBoxAccount.Text;
            string folder    = comboBoxFolder.Text;
            string pattern   = txtDeployment.Text;
            bool   success   = TaskGroup.ReadFromFile(connectionString, container, folder, pattern);

            if (success)
            {
                int index = comboBoxFolder.FindString(folder);
                if (index == -1)
                {
                    comboBoxFolder.Items.Add(folder);
                }
            }

            RefreshData();

            foreach (TaskGroup m in TaskGroup.TaskGroups.Values)
            {
                m.Intervals.Clear();
            }
        }
Beispiel #3
0
        public static bool ReadFromFile(string connectionString, string container, string folder, string pattern)
        {
            long minticks = long.MaxValue;
            long maxticks = 0;

            CloudStorageAccount storageaccount = CloudStorageAccount.Parse(connectionString);
            CloudBlobClient     blobClient     = storageaccount.CreateCloudBlobClient();

            var blobcontainer = blobClient.GetContainerReference(container);

            try
            {
                blobcontainer.FetchAttributes();
                // the container exists if no exception is thrown
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                return(false);
            }


            int taskmetercounter = 0;
            int filecount        = 0;

            // read all events in all files
            String readFromFolder;

            if (folder.Contains("%"))
            {
                readFromFolder = Uri.UnescapeDataString(folder);
            }
            else
            {
                readFromFolder = folder;
            }

            Regex deploymentRegex = new Regex("^.*");

            foreach (var x in blobcontainer.ListBlobs(folder))
            {
                var blockblob = x as CloudBlockBlob;
                if (blockblob == null || !deploymentRegex.IsMatch(blockblob.Name))
                {
                    continue;
                }

                var serializer = new JsonSerializer();

                using (var blobstream = blockblob.OpenRead())
                    using (var sr = new StreamReader(blobstream))
                        using (var jsonTextReader = new JsonTextReader(sr))
                        {
                            var content = (EventsBlobFormat)serializer.Deserialize(jsonTextReader, typeof(EventsBlobFormat));

                            bool callerOnly = true;

                            foreach (var e in content.Events)
                            {
                                if (!callerOnly || e.opSide == "Caller")
                                {
                                    var groupname = $"{e.name}({e.opType})";
                                    var reqno     = e.name.GetHashCode();
                                    var end       = TimeSpan.FromMilliseconds(e.time).Ticks;
                                    var start     = end - TimeSpan.FromMilliseconds(e.duration).Ticks;;

                                    if (!callerOnly)
                                    {
                                        groupname = groupname + $"({e.opSide})";
                                    }

                                    if (minticks > start)
                                    {
                                        minticks = start;
                                    }
                                    if (maxticks < end)
                                    {
                                        maxticks = end;
                                    }

                                    if (string.IsNullOrEmpty(pattern) || groupname.Contains(pattern))
                                    {
                                        TaskGroup meter = null;
                                        if (!TaskGroups.TryGetValue(groupname, out meter))
                                        {
                                            meter = new TaskGroup()
                                            {
                                                Name = groupname, seqnum = taskmetercounter++
                                            };
                                            TaskGroups[groupname] = meter;
                                        }

                                        meter.temp.Add(new Interval(start, end, reqno, filecount));
                                    }
                                }
                            }
                        }

                // sort intervals and assign thread
                foreach (var meter in TaskGroups.Values)
                {
                    meter.temp.Sort();
                    var threads = new List <long>();

                    foreach (var interval in meter.temp)
                    {
                        interval.Tid = meter.threadoffset + FindAvailableThread(threads, interval.Start, interval.End);
                    }

                    meter.threadoffset += threads.Count();

                    meter.Intervals.AddRange(meter.temp);
                    meter.temp.Clear();
                }

                filecount++;
            }

            if (minticks > maxticks)
            {
                minticks = 0;
                maxticks = 1;
            }

            TaskGroup.offset = minticks;
            TaskGroup.end    = maxticks - minticks;

            return(true);
        }
Beispiel #4
0
 public Display(Stats owner, TaskGroup meter)
 {
     this.owner = owner;
     this.meter = meter;
     task       = meter.Name;
 }
Beispiel #5
0
        private void dataGridView1_UserDeletingRow(object sender, DataGridViewRowCancelEventArgs e)
        {
            TaskGroup meter = (e.Row.Cells[display_col].Value as Display).meter;

            meter.Enabled = false;
        }
Beispiel #6
0
        public void RefreshData()
        {
            // set defaults
            this.maxticks = 1 + (long)(TaskGroup.end * 1.2); // leave some extra room on the right
            this.scale    = ((double)1) / TimeSpan.TicksPerMillisecond;
            leftticks     = 0;
            widthticks    = maxticks;

            // add missing rows / delete superfluous rows
            {
                Dictionary <TaskGroup, List <Display> > displaymap  = new Dictionary <TaskGroup, List <ReactiveMachine.Tools.Taskometer.Display> >();
                Dictionary <DataGridViewRow, bool>      toberemoved = new Dictionary <DataGridViewRow, bool>();

                foreach (DataGridViewRow r in dataGridView1.Rows)
                {
                    Display   display = r.Cells[display_col].Value as Display;
                    TaskGroup meter   = display.meter;
                    List <ReactiveMachine.Tools.Taskometer.Display> dlist;
                    if (meter.Intervals == null)
                    {
                        toberemoved.Add(r, true);
                    }
                    else
                    {
                        if (!displaymap.TryGetValue(meter, out dlist))
                        {
                            displaymap.Add(meter, dlist = new List <ReactiveMachine.Tools.Taskometer.Display>());
                        }
                        while (dlist.Count <= 0)
                        {
                            dlist.Add(null);
                        }
                        dlist[0] = display;
                    }
                }
                foreach (DataGridViewRow r in toberemoved.Keys)
                {
                    dataGridView1.Rows.Remove(r);
                }

                lock (TaskGroup.TaskGroups)
                {
                    foreach (TaskGroup m in TaskGroup.TaskGroups.Values)
                    {
                        if (m.Intervals != null)
                        {
                            List <ReactiveMachine.Tools.Taskometer.Display> dlist;
                            if (!displaymap.TryGetValue(m, out dlist))
                            {
                                displaymap.Add(m, dlist = new List <ReactiveMachine.Tools.Taskometer.Display>());
                            }

                            while (dlist.Count <= 0)
                            {
                                dlist.Add(null);
                            }
                            if (dlist[0] == null)
                            {
                                Display d = new Display(this, m);
                                dataGridView1.Rows.Add(d.Format());
                                dlist[0] = d;
                            }
                        }
                    }

                    dataGridView1.Sort(this);
                }

                foreach (DataGridViewRow r in dataGridView1.Rows)
                {
                    (r.Cells[display_col].Value as Display).RefreshData();
                }

                UpdateScrollBar();
                UpdateTextBox();
                UpdateZoom();

                UpdateView();
            }
        }