Exemplo n.º 1
0
        public static FusionBenchmarkResults BenchMarkingWithAllSigners(bool isoptimal, DataSetLoader offlineLoader, DataSetLoader onlineLoader)
        {
            var offlineSigners = offlineLoader.EnumerateSigners().ToList();
            var onlineSigners  = onlineLoader.EnumerateSigners().ToList();


            var offlinePipeline = FusionPipelines.GetOfflinePipeline();
            var onlinePipeline  = FusionPipelines.GetOnlinePipeline();
            var fusionPipeline  = FusionPipelines.GetFusionPipeline(onlineSigners, false, 0);

            var offOnSigners = new List <Signer>();
            var onOffSigners = new List <Signer>();

            Parallel.ForEach(offlineSigners, offSigner =>
            {
                try
                {
                    Console.WriteLine(offSigner.ID + " started at " + DateTime.Now.ToString("h:mm:ss tt"));
                    var onSigner = onlineSigners.Find(signer => signer.ID == offSigner.ID);
                    Parallel.ForEach(offSigner.Signatures, offSig =>
                    {
                        offlinePipeline.Transform(offSig);
                        var onSig = onSigner.Signatures.Find(sig => sig.ID == offSig.ID);
                        onSig.SetFeature <Image <Rgba32> >(FusionFeatures.Image, offSig.GetFeature(FusionFeatures.Image));
                        var onToOnPipeline = FusionPipelines.GetHackedOnToOnPipeline(offSig.GetFeature(FusionFeatures.Bounds));
                        onToOnPipeline.Transform(onSig);
                        onlinePipeline.Transform(onSig);
                    }
                                     );
                    Parallel.ForEach(offSigner.Signatures, offSig =>
                    {
                        fusionPipeline.Transform(offSig);
                        onlinePipeline.Transform(offSig);
                    }
                                     );

                    var offonSigner = FusionPipelines.GetMixedSigner(offSigner, onSigner);
                    var onoffSigner = FusionPipelines.GetMixedSigner(onSigner, offSigner);
                    offOnSigners.Add(offonSigner);
                    onOffSigners.Add(onoffSigner);
                    Console.WriteLine(offSigner.ID + " finished at " + DateTime.Now.ToString("h:mm:ss tt"));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }
                             );


            var offoffBenchmark = FusionPipelines.GetBenchmark(offlineSigners, isoptimal);
            var offonBenchmark  = FusionPipelines.GetBenchmark(offOnSigners, isoptimal);
            var onoffBenchamrk  = FusionPipelines.GetBenchmark(onOffSigners, isoptimal);
            var ononBenchmark   = FusionPipelines.GetBenchmark(onlineSigners, isoptimal);


            return(new FusionBenchmarkResults
            {
                OffOffResults = offoffBenchmark.Execute(),
                OffOnResults = offonBenchmark.Execute(),
                OnOffResults = onoffBenchamrk.Execute(),
                OnOnResults = ononBenchmark.Execute()
            });
        }
Exemplo n.º 2
0
        public FusionBenchmarkResults Execute()
        {
            var offlineSigners = OfflineLoader.EnumerateSigners().ToList();
            var onlineSigners  = OnlineLoader.EnumerateSigners().ToList();

            Console.WriteLine(offlineSigners.Count);
            Console.WriteLine(onlineSigners.Count);
            Console.WriteLine(offlineSigners[0].Signatures.Count);
            Console.WriteLine(onlineSigners[0].Signatures.Count);


            var offOnSigners = new List <Signer>();
            var onOffSigners = new List <Signer>();

            var fusionPipeline = FinalFusionPipelines.GetFusionPipeline(offlineSigners, true, InputBaseSigInputCntID);

            foreach (var offSigner in offlineSigners)
            {
                try
                {
                    Console.WriteLine(offSigner.ID + " started at " + DateTime.Now.ToString("h:mm:ss tt"));
                    var onSigner = onlineSigners.Find(signer => signer.ID == offSigner.ID);
                    Parallel.ForEach(offSigner.Signatures, offSig =>
                    {
                        try
                        {
                            MarosPipeline.Transform(offSig);
                            var onSig = onSigner.Signatures.Find(sig => sig.ID == offSig.ID);
                            onSig.SetFeature <Image <Rgba32> >(FusionFeatures.Image, offSig.GetFeature(FusionFeatures.Image));
                            var onToOnPipeline = FinalFusionPipelines.GetHackedOnToOnPipeline(offSig.GetFeature(FusionFeatures.Bounds));
                            onToOnPipeline.Transform(onSig);
                            OnlinePipeline.Transform(onSig);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                        }
                    }
                                     );
                    Parallel.ForEach(offSigner.Signatures, offSig =>
                    {
                        try
                        {
                            fusionPipeline.Transform(offSig);
                            OnlinePipeline.Transform(offSig);
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e.ToString());
                        }
                    }
                                     );

                    var offonSigner = FusionPipelines.GetMixedSigner(offSigner, onSigner);
                    var onoffSigner = FusionPipelines.GetMixedSigner(onSigner, offSigner);
                    offOnSigners.Add(offonSigner);
                    onOffSigners.Add(onoffSigner);


                    Console.WriteLine(offSigner.ID + " finished at " + DateTime.Now.ToString("h:mm:ss tt"));
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.ToString());
                }
            }

            var offoffBenchmark = FusionPipelines.GetBenchmark(offlineSigners, IsOptimal);
            var offonBenchmark  = FusionPipelines.GetBenchmark(offOnSigners, IsOptimal);
            var onoffBenchamrk  = FusionPipelines.GetBenchmark(onOffSigners, IsOptimal);
            var ononBenchmark   = FusionPipelines.GetBenchmark(onlineSigners, IsOptimal);


            return(new FusionBenchmarkResults
            {
                OffOffResults = offoffBenchmark.Execute(),
                OffOnResults = offonBenchmark.Execute(),
                OnOffResults = onoffBenchamrk.Execute(),
                OnOnResults = ononBenchmark.Execute()
            });
        }