Exemple #1
0
        public void replaceTxt()
        {
            /** TASK 1.2
             * TODO implement a loop that replaces the word hate to love in the files generated before (using a foreach-loop).
             * Therefore use the Method  _replaceTextInFile(FilePath)
             * Hint: The path to all generated files can looks like
             * String[] path = Directory.EnumerateFiles(path_seriell, "*.txt")   //replace path_seriell to path_parallel for parallel data
             *
             * Implement ths function with a normal loop and a parallel loop and measure the time that is needed to generate the data
             * Save the data in two different folder (path_seriell and path_parallel)
             */

            PerformanceMeasuring _perfMes_sequentialTxt = new PerformanceMeasuring("Text Replacement (sequential)");

            //implement sequential string replacement here

            _perfMes_sequentialTxt.stopMeasuring();


            // TO DO: parallel implementation
            PerformanceMeasuring _perfMes_parallelTxt = new PerformanceMeasuring("Text Replacement (parallel)");

            //implement parallel string replacement here

            _perfMes_parallelTxt.stopMeasuring();
        }
Exemple #2
0
        public void generateTxtFiles()
        {
            /** TASK 1.1
             * TODO implement a loop that generates 100 files (using a for-loop).
             * Therefore use the Method  _generateTextInFile(FilePath)
             * Hint: The path can be generated like:
             * string FilePath = path_seriell + @"File" + i.ToString() + ".txt"; //where i is the iteration number and change the path_seriell to path_parallel for paralel data
             *
             * Implement ths function with a normal loop and a parallel loop and measure the time that is needed to generate the data
             * Save the data in two different folder (path_seriell and path_parallel)
             */

            PerformanceMeasuring _perfMes_sequential = new PerformanceMeasuring("File Generation (sequential)");

            //implement sequential file generation here

            _perfMes_sequential.stopMeasuring();


            PerformanceMeasuring _perfMes_parallel = new PerformanceMeasuring("File Generation (parallel)");

            //implement parallel file generation here

            _perfMes_parallel.stopMeasuring();
        }
Exemple #3
0
        public void implicitTasks()
        {
            /* TASK 2.1
             * TODO:
             * write some code that calls the function
             *      longMeanCalculations() and pintMinMaxValues()
             *      and write some code lines that creates a file and saves the data in the file (every entry in a new line)
             *
             * Do this ina first step as a sequentiel code and measure the time needed
             * In a scond step use implicit tasks to do the job and compare the results
             *
             */
            double[] data = gernateData();
            measureTime = new PerformanceMeasuring("Sequential Calculations");
            //place here code for sequntial running the tasks
            printMinMaxValues(data);
            longMeanCalculations(data);

            using (StreamWriter sw = File.CreateText("tempSeq.txt")) {
                foreach (var temp in data)
                {
                    sw.WriteLine(temp.ToString());
                }
            }

            measureTime.stopMeasuring();

            measureTime = new PerformanceMeasuring("Parallel Calculations");
            //place here code for parallel running the tasks
            Parallel.Invoke(
                () => printMinMaxValues(data),
                () => longMeanCalculations(data),
                () =>
            {
                using (StreamWriter sw = File.CreateText("tempPara.txt"))
                {
                    foreach (var temp in data)
                    {
                        sw.WriteLine(temp.ToString());
                    }
                }
            }
                );
            measureTime.stopMeasuring();
        }
        public void implicitTasks()
        {
            /* TASK 2.1
             * TODO:
             * write some code that calls the function
             *      longMeanCalculations() and pintMinMaxValues()
             *      and write some code lines that creates a file and saves the data in the file (every entry in a new line)
             *
             * Do this ina first step as a sequentiel code and measure the time needed
             * In a scond step use implicit tasks to do the job and compare the results
             *
             */
            double[] data = gernateData();
            measureTime = new PerformanceMeasuring("Sequential Calculations");
            //place here code for sequntial running the tasks


            measureTime.stopMeasuring();

            measureTime = new PerformanceMeasuring("Parallel Calculations");
            //place here code for parallel running the tasks

            measureTime.stopMeasuring();
        }