Esempio n. 1
0
        /// <summary>
        /// Defines the benchmark and saves the benchmark file to provided in BenchmarkInfo filepath.
        ///
        /// </summary>
        public void Define()
        {
            if (string.IsNullOrEmpty(BenchmarkInfo.FilePath))
            {
                throw new ArgumentException("Benchmark File Path has not been provided. It cannot be null or empty");
            }
            if (System.IO.Path.IsPathRooted(BenchmarkInfo.FilePath) == false)
            {
                throw new ArgumentException("Benchmark File Path has to be absolute.");
            }
            if (SelectedTemplateNode == null)
            {
                throw new ArgumentNullException("Missing selected template node.");
            }

            Experiment benchmark = (Experiment)m_baseExperiment.Clone();

            //save original experiment path
            string originalExperimentPath = benchmark.ExperimentInfo.FilePath;

            //replace experiment info with benchmark info
            benchmark.ExperimentInfo = BenchmarkInfo;

            var experimentSerializer = new BenchmarkSerializer(m_library, m_dataRoot);

            //find the node that has to be replaced with ComponentTemplateMetadata
            foreach (ExperimentNode node in benchmark.Vertices)
            {
                if (node.Equals(SelectedTemplateNode))
                {
                    //get current metadata
                    var currentMetadata = node.Data.Metadata as IConfigurableAndIOSpecifiable;
                    if (currentMetadata != null)
                    {
                        //replace the current metadata with the ComponentTemplateMetadata
                        //provide the same IOSpec that was in current metadata.
                        //note that configuration is ignored
                        node.Data.Metadata = new ComponentTemplateMetadata(currentMetadata.IOSpec, currentMetadata.Label);
                    }
                }
            }

            System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings();
            settings.Indent = true;
            using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(benchmark.ExperimentInfo.FilePath, settings))
            {
                SelectedExperimentResults.TechniqueName = "BASELINE";
                experimentSerializer.SerializeExperiment(benchmark, SelectedExperimentResults, writer);
            }
        }
        /// <summary>
        /// Defines the benchmark and saves the benchmark file to provided in BenchmarkInfo filepath.
        /// 
        /// </summary>
        public void Define()
        {
            if (string.IsNullOrEmpty(BenchmarkInfo.FilePath))
                throw new ArgumentException("Benchmark File Path has not been provided. It cannot be null or empty");
            if (System.IO.Path.IsPathRooted(BenchmarkInfo.FilePath) == false)
                throw new ArgumentException("Benchmark File Path has to be absolute.");
            if (SelectedTemplateNode == null)
                throw new ArgumentNullException("Missing selected template node.");

            Experiment benchmark = (Experiment)m_baseExperiment.Clone();
            
            //save original experiment path
            string originalExperimentPath = benchmark.ExperimentInfo.FilePath;

            //replace experiment info with benchmark info
            benchmark.ExperimentInfo = BenchmarkInfo;
            
            var experimentSerializer = new BenchmarkSerializer(m_library, m_dataRoot);

            //find the node that has to be replaced with ComponentTemplateMetadata
            foreach(ExperimentNode node in benchmark.Vertices) 
            {
                if (node.Equals(SelectedTemplateNode))
                {
                    //get current metadata
                    var currentMetadata = node.Data.Metadata as IConfigurableAndIOSpecifiable;
                    if (currentMetadata != null)
                    {
                        //replace the current metadata with the ComponentTemplateMetadata
                        //provide the same IOSpec that was in current metadata. 
                        //note that configuration is ignored
                        node.Data.Metadata = new ComponentTemplateMetadata(currentMetadata.IOSpec, currentMetadata.Label);
                    }
                }
            }

            System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings();
            settings.Indent = true;
            using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(benchmark.ExperimentInfo.FilePath, settings))
            {
                SelectedExperimentResults.TechniqueName = "BASELINE";
                experimentSerializer.SerializeExperiment(benchmark, SelectedExperimentResults, writer);
            }
        }