예제 #1
0
파일: Program.cs 프로젝트: su636/voxeliq
        static TimeSpan MeasureParallelForeach(IEnumerable <string> feedSources)
        {
            var stopwatch = new Stopwatch();

            stopwatch.Start();

            Parallel.ForEach(feedSources, feedSource =>
            {
                var f = new FeedParser(feedSource);
            }
                             );

            stopwatch.Stop();
            return(stopwatch.Elapsed);
        }
예제 #2
0
 static void TPLFeedParserTask(string feedSource)
 {
     var f = new FeedParser(feedSource);
 }
예제 #3
0
 static void ThreadPoolTask(object data)
 {
     var f = new FeedParser(((ThreadPoolDataWrapper) data).FeedSource);
     (data as ThreadPoolDataWrapper).ResetEvent.Set();
 }
예제 #4
0
        static TimeSpan MeasureParallelForeach(IEnumerable<string> feedSources)
        {
            var stopwatch = new Stopwatch();
            stopwatch.Start();

            Parallel.ForEach(feedSources, feedSource =>
                                              {
                                                  var f = new FeedParser(feedSource);
                                              }
            );

            stopwatch.Stop();
            return stopwatch.Elapsed;
        }
예제 #5
0
        static void ThreadPoolTask(object data)
        {
            var f = new FeedParser(((ThreadPoolDataWrapper) data).FeedSource);
            f.Parse();
            var threadPoolDataWrapper = data as ThreadPoolDataWrapper;

            if (threadPoolDataWrapper != null) 
                threadPoolDataWrapper.ResetEvent.Set();
        }
예제 #6
0
        /// <summary>
        /// Measures threaded version.
        /// </summary>
        /// <param name="feedSources"></param>
        /// <returns></returns>
		private static TimeSpan MeasureThreads(IList<string> feedSources)
		{
            var stopwatch = new Stopwatch();
            stopwatch.Start();

			var threads = new Thread[feedSources.Count];

			for (var i = 0; i < feedSources.Count; i++)
			{
                var source = feedSources[i]; /* work-around modified closures */
				var feedParser = new FeedParser(source);
				threads[i] = new Thread(() => feedParser.Parse());
				threads[i].Start();
			}

			foreach (var thread in threads)
			{
				thread.Join();
			}

            stopwatch.Stop();
            return stopwatch.Elapsed;            
		}
예제 #7
0
파일: Program.cs 프로젝트: su636/voxeliq
        static void ThreadPoolTask(object data)
        {
            var f = new FeedParser(((ThreadPoolDataWrapper)data).FeedSource);

            (data as ThreadPoolDataWrapper).ResetEvent.Set();
        }
예제 #8
0
파일: Program.cs 프로젝트: su636/voxeliq
 static void TPLFeedParserTask(string feedSource)
 {
     var f = new FeedParser(feedSource);
 }