Ejemplo n.º 1
0
 public void AddRow(CSVRow r)
 {
     if (_data == null)
     {
         _data = new CSVData(_dataFilename);
     }
     _data.AddRow(r);
 }
Ejemplo n.º 2
0
        protected string Subdir(CSVRow row)
        {
            string suffix     = Suffix(row);
            int    subdir_inx = suffix.IndexOf("\\");
            string subdir     = suffix == "" ? "" : (subdir_inx < 0 ? suffix : suffix.Substring(0, subdir_inx));

            if (subdir.Length > 0)
            {
                if (!_statistics.subdirs.ContainsKey(subdir))
                {
                    _statistics.subdirs.Add(subdir, new ComparisonStatistics());
                }
            }
            return(subdir);
        }
Ejemplo n.º 3
0
 public void AddRow(CSVRow r)
 {
     _file.Seek(0, SeekOrigin.End);
     if (_writer == null)
     {
         _writer = new StreamWriter(_file);
     }
     foreach (string s in r.Data)
     {
         _writer.Write(s);
         _writer.Write(',');
     }
     _writer.WriteLine();
     _writer.Flush();
 }
Ejemplo n.º 4
0
        protected string Suffix(CSVRow row)
        {
            int liobs = row.Filename.LastIndexOf("\\");

            if (liobs <= _prefixLength)
            {
                return("");
            }
            string prefix = row.Filename.Substring(0, liobs);
            string suffix = row.Filename.Substring(_prefixLength, liobs - _prefixLength);

            if (suffix.Length > 0 && !_statistics.postfixes.ContainsKey(suffix))
            {
                _statistics.postfixes.Add(suffix, new ComparisonStatistics());
            }
            return(suffix);
        }
Ejemplo n.º 5
0
        protected void AddStatisticsY(CSVRow row)
        {
            _statistics.y_files++;

            if (row.ResultCode == ResultCode.OK)
            {
                double results         = (row.SAT + row.UNSAT + row.UNKNOWN);
                double y_ratio_sat     = (results == 0) ? 0 : row.SAT / results;
                double y_ratio_unsat   = (results == 0) ? 0 : row.UNSAT / results;
                double y_ratio_unknown = (results == 0) ? 0 : row.UNKNOWN / results;

                _statistics.y_cumulativeTimeSAT     += y_ratio_sat * row.Runtime;
                _statistics.y_cumulativeTimeUNSAT   += y_ratio_unsat * row.Runtime;
                _statistics.y_cumulativeTimeUNKNOWN += y_ratio_unknown * row.Runtime;
                _statistics.y_countSAT     += row.SAT;
                _statistics.y_countUNSAT   += row.UNSAT;
                _statistics.y_countUNKNOWN += row.UNKNOWN;

                string suffix = Suffix(row);
                string subdir = Subdir(row);

                if (suffix.Length > 0)
                {
                    _statistics.postfixes[suffix].y_files++;
                    _statistics.postfixes[suffix].y_cumulativeTimeSAT     += y_ratio_sat * row.Runtime;
                    _statistics.postfixes[suffix].y_cumulativeTimeUNSAT   += y_ratio_unsat * row.Runtime;
                    _statistics.postfixes[suffix].y_cumulativeTimeUNKNOWN += y_ratio_unknown * row.Runtime;
                    _statistics.postfixes[suffix].y_countSAT     += row.SAT;
                    _statistics.postfixes[suffix].y_countUNSAT   += row.UNSAT;
                    _statistics.postfixes[suffix].y_countUNKNOWN += row.UNKNOWN;
                }

                if (subdir.Length > 0)
                {
                    _statistics.subdirs[subdir].y_files++;
                    _statistics.subdirs[subdir].y_cumulativeTimeSAT     += y_ratio_sat * row.Runtime;
                    _statistics.subdirs[subdir].y_cumulativeTimeUNSAT   += y_ratio_unsat * row.Runtime;
                    _statistics.subdirs[subdir].y_cumulativeTimeUNKNOWN += y_ratio_unknown * row.Runtime;
                    _statistics.subdirs[subdir].y_countSAT     += row.SAT;
                    _statistics.subdirs[subdir].y_countUNSAT   += row.UNSAT;
                    _statistics.subdirs[subdir].y_countUNKNOWN += row.UNKNOWN;
                }
            }
        }
Ejemplo n.º 6
0
        protected void AddDataPoint(CSVRow xr, CSVRow yr)
        {
            double xrt = (xr.Runtime < _minX) ? _minX : xr.Runtime;
            double yrt = (yr.Runtime < _minY) ? _minY : yr.Runtime;

            Comparison.Point p = new Point();
            p.tooltip = xr.Filename;

            switch (xr.ResultCode)
            {
            case ResultCode.MEMORY: p.x = _memX; break;

            case ResultCode.TIME: p.x = _tmeX; break;

            case ResultCode.OK: p.x = xrt; break;

            default: p.x = _errX; break;
            }

            switch (yr.ResultCode)
            {
            case ResultCode.MEMORY: p.y = _memY; break;

            case ResultCode.TIME: p.y = _tmeY; break;

            case ResultCode.OK: p.y = yrt; break;

            default: p.y = _errY; break;
            }

            if (xr.SAT > yr.SAT || xr.UNSAT > yr.UNSAT)
            {
                p.type = PointType.WORSE;
            }
            else if (xr.SAT < yr.SAT || xr.UNSAT < yr.UNSAT)
            {
                p.type = PointType.BETTER;
            }

            _datapoints.Add(p);
        }
Ejemplo n.º 7
0
        protected void AddStatisticsXY(CSVRow xr, CSVRow yr)
        {
            string suffix = Suffix(xr);
            string subdir = Subdir(xr);

            _statistics.Count += 1.0;

            if (xr.ResultCode == ResultCode.OK || yr.ResultCode == ResultCode.OK)
            {
                double delta;

                if (xr.ResultCode == ResultCode.OK && yr.ResultCode == ResultCode.OK)
                {
                    delta = yr.Runtime - xr.Runtime;
                }
                else if (xr.ResultCode == ResultCode.OK && yr.ResultCode != ResultCode.OK)
                {
                    delta = -_tmeY;
                }
                else
                {
                    delta = _tmeX;
                }

                _statistics.deltas.Add(delta);
                _statistics.deltas_sorted = false;
                if (suffix.Length > 0)
                {
                    _statistics.postfixes[suffix].deltas.Add(delta);
                    _statistics.postfixes[suffix].deltas_sorted = false;
                }

                if (subdir.Length > 0)
                {
                    _statistics.subdirs[subdir].deltas.Add(delta);
                    _statistics.subdirs[subdir].deltas_sorted = false;
                }
            }
        }
Ejemplo n.º 8
0
        protected void ComputeStatistics()
        {
            _datapoints           = new List <Point>();
            _statistics           = new ComparisonStatistics();
            _statistics.postfixes = new Dictionary <string, ComparisonStatistics>();
            _statistics.subdirs   = new Dictionary <string, ComparisonStatistics>();

            if (_jX == null || _jY == null)
            {
                return;
            }
            if (_jX.Rows.Count == 0 || _jY.Rows.Count == 0)
            {
                return;
            }

            _jX.Rows.Sort(csvrow_lt);
            _jY.Rows.Sort(csvrow_lt);

            List <CSVRow> .Enumerator yit = _jY.Rows.GetEnumerator();
            yit.MoveNext();
            CSVRow yr = yit.Current;

            if (yr.Filename.StartsWith(_prefix))
            {
                AddStatisticsY(yr);
            }
            string last_x = null, last_y = null;

            foreach (CSVRow xr in _jX.Rows)
            {
                if (!xr.Filename.StartsWith(_prefix) ||
                    (last_x != null && last_x.CompareTo(xr.Filename) == 0)) // ignore duplicates.
                {
                    continue;
                }

                do
                {
                    if (yr.Filename.CompareTo(xr.Filename) >= 0)
                    {
                        break;
                    }
                    last_y = yr.Filename;
                    while (yit.Current.Filename == last_y) // ignore duplicates.
                    {
                        if (!yit.MoveNext())
                        {
                            yr = null; break;
                        }
                        else
                        {
                            yr = yit.Current;
                        }
                    }
                    if (yr != null && yr.Filename.StartsWith(_prefix))
                    {
                        AddStatisticsY(yr);
                    }
                }while (yr != null);

                if (yr == null)
                {
                    continue;
                }

                AddStatisticsX(xr);

                if (yr.Filename.CompareTo(xr.Filename) == 0)
                {
                    AddStatisticsXY(xr, yr);
                    AddDataPoint(xr, yr);
                }

                last_x = xr.Filename;
            }
        }
Ejemplo n.º 9
0
 protected static int csvrow_lt(CSVRow x, CSVRow y)
 {
     return(x.Filename.CompareTo(y.Filename));
 }
Ejemplo n.º 10
0
        protected bool ParseRow(CSVRow r, HashSet <string> seen)
        {
            string category = r.Filename.Substring(0, r.Filename.IndexOf(@"\"));

            if (category == "")
            {
                throw new Exception("Empty category string in `" + r.Filename + "'");
            }

            if (!ContainsKey(category))
            {
                Add(category, new CategoryStatistics());
            }

            if (seen.Contains(r.Filename))
            {
                // Global.Say("Duplicate: " + r.Filename);
                return(false);
            }
            else
            {
                seen.Add(r.Filename);
            }

            CategoryStatistics cs = this[category];

            switch (r.ResultCode)
            {
            case ResultCode.OK:
            {
                cs.SAT     += r.SAT;
                cs.UNSAT   += r.UNSAT;
                cs.UNKNOWN += r.UNKNOWN;
                if (r.SAT > 0)
                {
                    cs.TimeSAT += r.Runtime;
                }
                if (r.UNSAT > 0)
                {
                    cs.TimeUNSAT += r.Runtime;
                }
                if ((r.SAT + r.UNSAT) > (r.TargetSAT + r.TargetUNSAT) && (r.UNKNOWN < r.TargetUNKNOWN))
                {
                    cs.Overperformers++;
                }
                if ((r.SAT + r.UNSAT) < (r.TargetSAT + r.TargetUNSAT) || (r.UNKNOWN > r.TargetUNKNOWN))
                {
                    cs.UnderPerformers++;
                }
                break;
            }

            case ResultCode.BUG: cs.Bugs++; break;

            case ResultCode.ERROR:
            {
                if (r.StdErr.StartsWith("INFRASTRUCTURE ERROR:"))
                {
                    cs.InfrastructureErrors++;
                }
                else
                {
                    cs.Errors++;
                }
                cs.SAT     += r.SAT;
                cs.UNSAT   += r.UNSAT;
                cs.UNKNOWN += r.UNKNOWN;
                if (r.SAT > 0)
                {
                    cs.TimeSAT += r.Runtime;
                }
                if (r.UNSAT > 0)
                {
                    cs.TimeUNSAT += r.Runtime;
                }

                if ((r.SAT + r.UNSAT) < (r.TargetSAT + r.TargetUNSAT) || (r.UNKNOWN > r.TargetUNKNOWN))
                {
                    cs.UnderPerformers++;
                }
                break;
            }

            case ResultCode.TIME:
            {
                cs.Timeout++;
                cs.SAT     += r.SAT;
                cs.UNSAT   += r.UNSAT;
                cs.UNKNOWN += r.UNKNOWN;
                if (r.SAT > 0)
                {
                    cs.TimeSAT += r.Runtime;
                }
                if (r.UNSAT > 0)
                {
                    cs.TimeUNSAT += r.Runtime;
                }

                if ((r.SAT + r.UNSAT) < (r.TargetSAT + r.TargetUNSAT) || (r.UNKNOWN > r.TargetUNKNOWN))
                {
                    cs.UnderPerformers++;
                }
                break;
            }

            case ResultCode.MEMORY:
            {
                cs.Memout++;
                cs.SAT     += r.SAT;
                cs.UNSAT   += r.UNSAT;
                cs.UNKNOWN += r.UNKNOWN;
                if (r.SAT > 0)
                {
                    cs.TimeSAT += r.Runtime;
                }
                if (r.UNSAT > 0)
                {
                    cs.TimeUNSAT += r.Runtime;
                }

                if ((r.SAT + r.UNSAT) < (r.TargetSAT + r.TargetUNSAT) || (r.UNKNOWN > r.TargetUNKNOWN))
                {
                    cs.UnderPerformers++;
                }
                break;
            }

            default: throw new Exception("Unexpected result code: " + r.ResultCode);
            }

            cs.Files++;

            return(true);
        }