Esempio n. 1
0
        private void WriteResult(BenchmarkResult result, StreamWriter writer, bool last)
        {
            string name = Path.GetFileName(result.File.Path);

            if (result.Exception != null)
            {
                writer.WriteLine("    {{ \"file\": \"{0}\", \"exception\": \"{1}\" }},", name, result.Exception);

                return;
            }

            writer.WriteLine("    {{ \"file\": \"{0}\", \"size\": {1}, \"values\": {2}, \"time\": {3}, \"error\": {4} }}{5}",
                             name, result.RowCount, result.NonZerosCount,
                             result.Time.ToString("0.000", CultureInfo.InvariantCulture),
                             result.Residual.ToString("0.00000e00", CultureInfo.InvariantCulture),
                             last ? "" : ",");
        }
Esempio n. 2
0
        private void Run(MatrixFile file, Stopwatch timer, List <BenchmarkResult> results)
        {
            string name = Path.GetFileName(file.Path);

            if (!File.Exists(file.Path))
            {
                results.Add(new BenchmarkResult(file, "File not found."));

                return;
            }

            try
            {
                var A = (CompressedColumnStorage <T>)file.Matrix;

                if (A == null)
                {
                    A = MatrixMarketReader.ReadMatrix <T>(file.Path);
                }

                int columns = A.ColumnCount;

                var x = CreateTestVector(columns);
                var s = CreateTestVector(columns);
                var b = new T[A.RowCount];

                A.Multiply(x, b);

                Array.Clear(x, 0, columns);

                var info = new BenchmarkResult(file, A.RowCount, columns, GetNonZerosCount(A));

                info.Time = Solve(A, b, x, file.Symmetric, timer);

                info.Residual = ComputeError(x, s);

                results.Add(info);
            }
            catch (Exception e)
            {
                results.Add(new BenchmarkResult(file, e.Message));
            }
        }