Example #1
0
        protected async void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string summaryName = Request.Params.Get("summary");
                summaryName = summaryName == null ? Settings.Default.SummaryName : summaryName;

                string connectionString = await SiteMaster.GetConnectionString();

                AzureSummaryManager summaryManager = new AzureSummaryManager(connectionString, Helpers.GetDomainResolver());

                string px = null, py = null;
                Tags   tags = await Helpers.GetTags(summaryName, summaryManager);

                if (!IsPostBack)
                {
                    var last2 = await Helpers.GetTwoLastExperimentsId(summaryName, summaryManager);

                    string penultimate = last2.Item1.ToString();
                    string latest      = last2.Item2.ToString();

                    lstTagX.Items.Add(new ListItem("Latest (" + latest + ")", latest));
                    lstTagX.Items.Add(new ListItem("Penultimate (" + penultimate + ")", penultimate));
                    //lstTagX.Items.Add(new ListItem("Records (best ever)", "RECORDS"));
                    lstTagY.Items.Add(new ListItem("Latest (" + latest + ")", latest));
                    lstTagY.Items.Add(new ListItem("Penultimate (" + penultimate + ")", penultimate));

                    foreach (KeyValuePair <string, int> kvp in tags)
                    {
                        lstTagX.Items.Add(new ListItem(kvp.Key + " (" + kvp.Value.ToString() + ")", kvp.Value.ToString()));
                        lstTagY.Items.Add(new ListItem(kvp.Key + " (" + kvp.Value.ToString() + ")", kvp.Value.ToString()));
                    }

                    px     = Request.Params.Get("jobX");
                    py     = Request.Params.Get("jobY");
                    Prefix = Request.Params.Get("prefix");

                    if (px == null)
                    {
                        rbnTagX.Checked = true;
                    }
                    else
                    {
                        txtIDX.Text = px; rbnIDX.Checked = true;
                    }
                    if (py == null)
                    {
                        rbnTagY.Checked = true;
                    }
                    else
                    {
                        txtIDY.Text = py; rbnIDY.Checked = true;
                    }

                    if (px != null)
                    {
                        if (tags.HasID(int.Parse(px, CultureInfo.InvariantCulture)))
                        {
                            rbnTagX.Checked       = true;
                            lstTagX.SelectedValue = px;
                        }
                        else
                        {
                            lstTagX.SelectedValue = penultimate;
                        }
                    }
                    else
                    {
                        lstTagX.SelectedValue = penultimate;
                    }

                    if (py != null)
                    {
                        if (tags.HasID(int.Parse(py, CultureInfo.InvariantCulture)))
                        {
                            rbnTagY.Checked = true;
                            lstTagY.Items.FindByText(py.ToString());
                            lstTagY.SelectedValue = py.ToString();
                        }
                        else
                        {
                            lstTagY.SelectedValue = latest;
                        }
                    }
                    else
                    {
                        lstTagY.SelectedValue = latest;
                    }
                }

                JX = px != null ? px : rbnTagX.Checked ? lstTagX.SelectedValue : txtIDX.Text;
                JY = py != null ? py : rbnTagY.Checked ? lstTagY.SelectedValue : txtIDY.Text;

                ComparableExperiment jX = null, jY = null;

                try
                {
                    AzureExperimentManager expMan = AzureExperimentManager.Open(connectionString);
                    var t1 = Task.Run(() => Helpers.GetComparableExperiment(int.Parse(JX, CultureInfo.InvariantCulture), expMan));
                    var t2 = Task.Run(() => Helpers.GetComparableExperiment(int.Parse(JY, CultureInfo.InvariantCulture), expMan));

                    jX = await t1;
                    jY = await t2;
                }
                catch (Exception)
                {
                }

                txtIDX.Text = JX;
                txtIDY.Text = JY;

                cmp = new Comparison(jX, jY, Prefix.Replace('|', '/'), tags);

                phPre.Controls.Add(buildHeader("CHART_PRE", ""));
                phChart.Controls.Add(Charts.BuildComparisonChart(Prefix, cmp));
                phHisto.Controls.Add(Charts.BuildComparisonHistogramm(cmp));
                phMain.Controls.Add(buildTabPanels());
                //phMain.Controls.Add(buildFooter());
            }
            catch (Exception ex)
            {
                Label l = new Label();
                l.Text = "Error loading dataset: " + ex.Message;
                phMain.Controls.Add(l);
                l      = new Label();
                l.Text = "Stacktrace: " + ex.StackTrace;
                phMain.Controls.Add(l);
            }
        }
        public static async Task <Timeline> Initialize(string connectionString, string summaryName, AzureExperimentManager expManager, AzureSummaryManager summaryManager)
        {
            var summRec = await summaryManager.GetTimelineAndRecords(summaryName);

            var summ    = summRec.Item1;
            var records = summRec.Item2;
            var now     = DateTime.Now;

            var expTasks =
                summ
                .Select(async expSum =>
            {
                var exp = await expManager.TryFindExperiment(expSum.Id);
                if (exp == null)
                {
                    return(null);
                }

                bool isFinished;
                if (exp.Status.SubmissionTime.Subtract(now).TotalDays >= 3)
                {
                    isFinished = true;
                }
                else
                {
                    try
                    {
                        var jobState = await expManager.GetExperimentJobState(new[] { exp.ID });
                        isFinished   = jobState[0] != ExperimentExecutionState.Active;
                    }
                    catch
                    {
                        isFinished = true;
                    }
                }

                return(new ExperimentViewModel(expSum, isFinished, exp.Status.SubmissionTime, exp.Definition.BenchmarkTimeout));
            });

            var experiments = await Task.WhenAll(expTasks);

            return(new Timeline(expManager, summaryManager, summaryName, experiments, records));
        }