コード例 #1
0
        public static Report BuildReport([ActivityTrigger] ReportContext ctx, ILogger log)
        {
            var repo = new InMemoryMatrixMulRepository();

            repo.StoreCalculation("an_id", ctx.Calculation);
            repo.StoreResultMatrix("an_id", ctx.Result);
            var hndlr = new FunctionHandler(repo);

            log.LogInformation($"Building Report");
            return(hndlr.GenerateReport(ctx.CallbackURL, ctx.StartTime, "an_id", ctx.WorkerCount));
        }
コード例 #2
0
        public void TestParallelMulBySeed()
        {
            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 parallel Multiply");
            hndlr.ScheduleMultiplicationTasks(id, 5);
            var tasks = new List <Task>();

            for (int i = 0; i < 5; i++)
            {
                _out.WriteLine($"Running Worker #{i}");
                hndlr.ParallelMultiplyWorker(id, i);
            }

            _out.WriteLine("Building Result");
            hndlr.BuildResultMatrix(id, 5);

            _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);
        }
コード例 #3
0
        public JObject Main(JObject args)
        {
            try
            {
                var repo  = new CloudObjectStorageRepository(args);
                var hndlr = new FunctionHandler(repo);

                Console.WriteLine("Generating Report");

                var callback = "";
                if (args.ContainsKey("hasCallback") && args["hasCallback"].ToString() == "true")
                {
                    Console.WriteLine("Using Callback");
                    callback = args["callback"].ToString();
                }
                else
                {
                    callback = null;
                }

                Console.WriteLine("Reading Start Timestamp");
                var start = long.Parse(args["startTimestamp"].ToString());

                var report = hndlr.GenerateReport(callback, start, args["id"].ToString(),
                                                  int.Parse(args["worker_count"].ToString()));

                var l = JsonConvert.SerializeObject(report);

                Console.WriteLine(l);
                return(JObject.Parse(l));
            }
            catch (Exception e)
            {
                var j = new JObject();
                j["error"] = e.ToString();
                return(j);
            }
        }
コード例 #4
0
ファイル: Handler.cs プロジェクト: c-mueller/faas-migration
 public Report BuildReport(FunctionContext ctx)
 {
     return(handler.GenerateReport(ctx.CallbackUrl, ctx.Start, ctx.CalculationID, int.Parse(ctx.WorkerCount)));
 }