/// <summary>
 /// In a single thread loops through the useragents in the file
 /// provided perform a match with the data set provided passing
 /// control back to the method provided for further processing.
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="userAgents"></param>
 /// <param name="method"></param>
 /// <returns>Counts for each of the methods used</returns>
 internal static Results DetectLoopSingleThreaded(TrieProvider provider, IEnumerable<string> userAgents, ProcessTrie method, object state)
 {
     var results = new Results();
     foreach (var line in userAgents)
     {
         method(results, provider.GetDeviceIndex(line.Trim()), state);
         results.Count++;
     }
     ReportMethods(results.Methods);
     ReportTime(results);
     return results;
 }
Beispiel #2
0
        /// <summary>
        /// Using multiple threads loops through the useragents in the file
        /// provided perform a match with the data set provided passing
        /// control back to the method provided for further processing.
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="userAgents"></param>
        /// <param name="method"></param>
        /// <returns>Counts for each of the methods used</returns>
        internal static Results DetectLoopMultiThreaded(TrieProvider provider, IEnumerable <string> userAgents, ProcessTrie method, object state)
        {
            var results = new Results();

            Parallel.ForEach(userAgents, line =>
            {
                method(results, provider.GetDeviceIndex(line.Trim()), state);
                Interlocked.Increment(ref results.Count);
            });
            ReportMethods(results.Methods);
            ReportTime(results);
            return(results);
        }
 /// <summary>
 /// Using multiple threads loops through the useragents in the file
 /// provided perform a match with the data set provided passing
 /// control back to the method provided for further processing.
 /// </summary>
 /// <param name="provider"></param>
 /// <param name="userAgents"></param>
 /// <param name="method"></param>
 /// <returns>Counts for each of the methods used</returns>
 internal static Results DetectLoopMultiThreaded(TrieProvider provider, IEnumerable<string> userAgents, ProcessTrie method, object state)
 {
     var results = new Results();
     Parallel.ForEach(userAgents, line =>
     {
         method(results, provider.GetDeviceIndex(line.Trim()), state);
         Interlocked.Increment(ref results.Count);
     });
     ReportMethods(results.Methods);
     ReportTime(results);
     return results;
 }
Beispiel #4
0
        /// <summary>
        /// In a single thread loops through the useragents in the file
        /// provided perform a match with the data set provided passing
        /// control back to the method provided for further processing.
        /// </summary>
        /// <param name="provider"></param>
        /// <param name="userAgents"></param>
        /// <param name="method"></param>
        /// <returns>Counts for each of the methods used</returns>
        internal static Results DetectLoopSingleThreaded(TrieProvider provider, IEnumerable <string> userAgents, ProcessTrie method, object state)
        {
            var results = new Results();

            foreach (var line in userAgents)
            {
                method(results, provider.GetDeviceIndex(line.Trim()), state);
                results.Count++;
            }
            ReportMethods(results.Methods);
            ReportTime(results);
            return(results);
        }