public void TestSerialMulBySeed()
        {
            var start = Util.GetUnixTimestamp();

            _out.WriteLine($"Creating 2 {Size}x{Size} Matrices with Max Value {Max} based on seed {Seed}");
            var id = hndlr.CreateMatrix(Size, Max, Seed);

            _out.WriteLine($"Got ID {id}");

            _out.WriteLine($"Running serial Multiply");
            hndlr.SerialMultiply(id);

            _out.WriteLine("Creating Report");
            var report = hndlr.GenerateReport(null, start, id, 0);

            _out.WriteLine(report.ToString());

            _out.WriteLine("A:");
            _out.WriteLine(repo.GetCalculation(id).A.ToString());
            _out.WriteLine("B:");
            _out.WriteLine(repo.GetCalculation(id).B.ToString());
            _out.WriteLine("Result:");
            _out.WriteLine(repo.GetResultMatrix(id).ToString());

            Assert.Equal(121672, report.ResultMatrix.Average);
            Assert.Equal(78312, report.ResultMatrix.Minimum);
            Assert.Equal(168397, report.ResultMatrix.Maximum);
        }
예제 #2
0
        public static Matrix SerialMultiply([ActivityTrigger] MatrixCalculation calculation, ILogger log)
        {
            var repo = new InMemoryMatrixMulRepository();

            repo.StoreCalculation("an_id", calculation);
            var hndlr = new FunctionHandler(repo);

            log.LogInformation("Serially multiplying two matrices");
            hndlr.SerialMultiply("an_id");

            return(repo.GetResultMatrix("an_id"));
        }
예제 #3
0
        public JObject Main(JObject args)
        {
            try
            {
                var repo  = new CloudObjectStorageRepository(args);
                var hndlr = new FunctionHandler(repo);

                hndlr.SerialMultiply(args["id"].ToString());

                Console.WriteLine(args.ToString());
                return(args);
            }
            catch (Exception e)
            {
                var j = new JObject();
                j["error"] = e.ToString();
                return(j);
            }
        }
예제 #4
0
 public FunctionContext SerialMultiply(FunctionContext ctx)
 {
     handler.SerialMultiply(ctx.CalculationID);
     ctx.WorkerCount = "0";
     return(ctx);
 }